From eff81df43ed92b8a8ecc1fc27b69e25fac6f191d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 20 Feb 2016 03:33:56 +0000 Subject: https: ensure SERVER_PORT defaults to 443 This helps Rack::Request#url and similar methods generate proper URLs instead of the obviously wrong: "https://example.com:80/" Note: we don't track the actual port the listener is bound to, and it may not be worth it since the use of the Host: header is long-established and Host: headers include the port number if non-standard. --- test/test_ssl.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test_ssl.rb b/test/test_ssl.rb index fe7e09e..5fc2b52 100644 --- a/test/test_ssl.rb +++ b/test/test_ssl.rb @@ -71,7 +71,7 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC cfg.instance_eval do ru = lambda do |env| case path_info = env['PATH_INFO'] - when '/rack.url_scheme', '/HTTPS' + when '/rack.url_scheme', '/HTTPS', '/SERVER_PORT' s = env[path_info[1..-1]] # remove leading slash s = s.inspect if s.nil? [ 200, { @@ -100,7 +100,8 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC buf = ''.dup { '/' => 'HI', '/rack.url_scheme' => 'https', - '/HTTPS' => 'on' + '/HTTPS' => 'on', + '/SERVER_PORT' => '443', }.each do |path, exp| client.write("GET #{path} HTTP/1.1\r\nHost: example.com\r\n\r\n") buf.clear -- cgit v1.2.3-24-ge0c7