From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.8 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: yahns-public@yhbt.net Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5C48220453; Sat, 20 Feb 2016 21:44:54 +0000 (UTC) Date: Sat, 20 Feb 2016 21:44:54 +0000 From: Eric Wong To: yahns-public@yhbt.net Subject: [PATCH 2/1] test_ssl: check SERVER_PORT when parsed from Host: header Message-ID: <20160220214454.GA23169@dcvr.yhbt.net> References: <20160220033356.GA31676@dcvr.yhbt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160220033356.GA31676@dcvr.yhbt.net> List-Id: We need to ensure SERVER_PORT is still parsed from the Host: header when it is given, there. --- test/test_ssl.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 @@ def test_ssl_basic 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 -- EW