summaryrefslogtreecommitdiffstats
path: root/test/net/http
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-30 13:09:03 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-30 13:09:03 +0000
commit38a609683cec25f69f06e5389c9b77044cc85849 (patch)
tree6ebd84eb0b13537ceaf8d473aa3a076f55f71129 /test/net/http
parent9c9a6ca435ff123361d13d309274cbcaa0c0529b (diff)
downloadruby-38a609683cec25f69f06e5389c9b77044cc85849.tar.gz
ruby-38a609683cec25f69f06e5389c9b77044cc85849.tar.xz
ruby-38a609683cec25f69f06e5389c9b77044cc85849.zip
* lib/net/http.rb (Net::HTTPResponse#each_response_header):
accept multiline message header of HTTP response. see #1796. cf. RFC 2616 '4.2 Message Header'. * test/net/http/test_httpresponse.rb: added. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/http')
-rw-r--r--test/net/http/test_httpresponse.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/net/http/test_httpresponse.rb b/test/net/http/test_httpresponse.rb
new file mode 100644
index 000000000..ab6fdd0ea
--- /dev/null
+++ b/test/net/http/test_httpresponse.rb
@@ -0,0 +1,40 @@
+require 'net/http'
+require 'test/unit'
+require 'stringio'
+
+class HTTPResponseTest < Test::Unit::TestCase
+ def test_singleline_header
+ io = dummy_io(<<EOS.gsub(/\n/, "\r\n"))
+HTTP/1.1 200 OK
+Content-Length: 5
+Connection: close
+
+hello
+EOS
+ res = Net::HTTPResponse.read_new(io)
+ assert_equal('5', res.header['content-length'])
+ assert_equal('close', res.header['connection'])
+ end
+
+ def test_multiline_header
+ io = dummy_io(<<EOS.gsub(/\n/, "\r\n"))
+HTTP/1.1 200 OK
+X-Foo: XXX
+ YYY
+X-Bar:
+ XXX
+\tYYY
+
+hello
+EOS
+ res = Net::HTTPResponse.read_new(io)
+ assert_equal('XXX YYY', res.header['x-foo'])
+ assert_equal('XXX YYY', res.header['x-bar'])
+ end
+
+private
+
+ def dummy_io(str)
+ Net::BufferedIO.new(StringIO.new(str))
+ end
+end