diff options
author | Eric Wong <e@80x24.org> | 2016-02-20 21:36:48 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-02-20 21:43:43 +0000 |
commit | ac7503210f55272e0d841a754a991fa96d665a46 (patch) | |
tree | 4f3726caff9b7bf5abfa1e0a46e028446540b847 | |
parent | eff81df43ed92b8a8ecc1fc27b69e25fac6f191d (diff) | |
download | yahns-ac7503210f55272e0d841a754a991fa96d665a46.tar.gz |
We need to ensure SERVER_PORT is still parsed from the Host: header when it is given, there.
-rw-r--r-- | test/test_ssl.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test_ssl.rb b/test/test_ssl.rb index 5fc2b52..e89a89d 100644 --- a/test/test_ssl.rb +++ b/test/test_ssl.rb @@ -114,11 +114,25 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC assert_match %r{\AHTTP/1\.\d 200 OK\r\n}, head end + # use port in Host: header (implemented by unicorn_http parser) + exp = '666' + client.write("GET /SERVER_PORT HTTP/1.1\r\nHost: example.com:#{exp}\r\n\r\n") + re = /#{Regexp.escape(exp)}\z/ + buf.clear + Timeout.timeout(60) do + buf << client.readpartial(111) until buf =~ re + end + head, body = buf.split("\r\n\r\n", 2) + assert_equal exp, body + assert_match %r{\AHTTP/1\.\d 200 OK\r\n}, head + Net::HTTP.start(insecure.addr[3], insecure.addr[1]) do |h| res = h.get('/rack.url_scheme') assert_equal 'http', res.body res = h.get('/HTTPS') assert_equal 'nil', res.body + res = h.get('/SERVER_PORT') + assert_equal insecure.addr[1].to_s, res.body end # read static file |