Sha256: 6cf2c229fca2a66903091f8c4a83a3a88970623512a7d84c1f30a361a7fee430

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'test_helper'

module M2R
  class TestRequest < MiniTest::Unit::TestCase
    def test_parse
      data = %q[FAKESENDER 0 / 97:{"PATH":"/","host":"default","METHOD":"HEAD","VERSION":"HTTP/1.1","URI":"/","URL_SCHEME":"https"},0:,]
      request = Request.parse(data)

      assert_equal "/", request.path
      assert_equal "default", request.headers['Host']
      assert_equal "HEAD", request.method
      assert_equal nil, request.query
      assert_equal nil, request.pattern
      assert_equal "https", request.scheme
    end

    def test_scheme
      data = %q[FAKESENDER 0 / 96:{"PATH":"/","host":"default","METHOD":"HEAD","VERSION":"HTTP/1.1","URI":"/","URL_SCHEME":"http"},0:,]
      request = Request.parse(data)
      assert_equal "http", request.scheme
    end

    def test_http_scheme_in_mongrel17
      data = %q[FAKESENDER 0 / 76:{"PATH":"/","host":"default","METHOD":"HEAD","VERSION":"HTTP/1.1","URI":"/"},0:,]
      request = Request.parse(data)
      assert_equal "http", request.scheme
    end

    def test_https_scheme_in_mongrel17_set_via_env
      ENV['HTTPS']='true'
      data = %q[FAKESENDER 0 / 76:{"PATH":"/","host":"default","METHOD":"HEAD","VERSION":"HTTP/1.1","URI":"/"},0:,]
      request = Request.parse(data)
      assert_equal "https", request.scheme
    ensure
      ENV.delete('HTTPS')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
m2r-1.0.0 test/unit/request_test.rb