From 3dc43b27e2ab2740acda0514bb0d9562810b3df1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 21 Apr 2009 11:14:56 -0700 Subject: http11: support underscores in URI hostnames They aren't common, but apparently there exist URLs with them, so we'll support them. --- test/unit/test_http_parser.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/unit/test_http_parser.rb b/test/unit/test_http_parser.rb index ce1213f..45e051a 100644 --- a/test/unit/test_http_parser.rb +++ b/test/unit/test_http_parser.rb @@ -136,6 +136,22 @@ class HttpParserTest < Test::Unit::TestCase assert_equal '', req['QUERY_STRING'] end + # not common, but underscores do appear in practice + def test_absolute_uri_underscores + parser = HttpParser.new + req = {} + http = "GET http://under_score.example.com/foo?q=bar HTTP/1.0\r\n\r\n" + assert parser.execute(req, http) + assert_equal 'http', req['rack.url_scheme'] + assert_equal '/foo?q=bar', req['REQUEST_URI'] + assert_equal '/foo', req['REQUEST_PATH'] + assert_equal 'q=bar', req['QUERY_STRING'] + + assert_equal 'under_score.example.com', req['HTTP_HOST'] + assert_equal 'under_score.example.com', req['SERVER_NAME'] + assert_equal '80', req['SERVER_PORT'] + end + def test_absolute_uri parser = HttpParser.new req = {} -- cgit v1.2.3-24-ge0c7