1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/webrick/httprequest.rb (WEBrick::HTTPReuqest#parse_uri): improve

for the value of IPv6 address in the Host: header field.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2006-07-31 04:39:45 +00:00
parent b3e961b32b
commit ddc38a6abb
3 changed files with 65 additions and 1 deletions

View file

@ -111,6 +111,64 @@ class TestWEBrickHTTPRequest < Test::Unit::TestCase
assert_equal("hogehoge\n", req.body)
end
def test_parse_headers3
msg = <<-_end_of_message_
GET /path HTTP/1.1
Host: test.ruby-lang.org
_end_of_message_
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
assert_equal(URI.parse("http://test.ruby-lang.org/path"), req.request_uri)
assert_equal("test.ruby-lang.org", req.host)
assert_equal(80, req.port)
msg = <<-_end_of_message_
GET /path HTTP/1.1
Host: 192.168.1.1
_end_of_message_
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
assert_equal(URI.parse("http://192.168.1.1/path"), req.request_uri)
assert_equal("192.168.1.1", req.host)
assert_equal(80, req.port)
msg = <<-_end_of_message_
GET /path HTTP/1.1
Host: [fe80::208:dff:feef:98c7]
_end_of_message_
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
assert_equal(URI.parse("http://[fe80::208:dff:feef:98c7]/path"),
req.request_uri)
assert_equal("[fe80::208:dff:feef:98c7]", req.host)
assert_equal(80, req.port)
msg = <<-_end_of_message_
GET /path HTTP/1.1
Host: 192.168.1.1:8080
_end_of_message_
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
assert_equal(URI.parse("http://192.168.1.1:8080/path"), req.request_uri)
assert_equal("192.168.1.1", req.host)
assert_equal(8080, req.port)
msg = <<-_end_of_message_
GET /path HTTP/1.1
Host: [fe80::208:dff:feef:98c7]:8080
_end_of_message_
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
assert_equal(URI.parse("http://[fe80::208:dff:feef:98c7]:8080/path"),
req.request_uri)
assert_equal("[fe80::208:dff:feef:98c7]", req.host)
assert_equal(8080, req.port)
end
def test_parse_get_params
param = "foo=1;foo=2;foo=3;bar=x"