mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@25579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
104c5f6b55
commit
d1cb4a5ba7
3 changed files with 58 additions and 3 deletions
40
test/net/http/test_httpresponse.rb
Normal file
40
test/net/http/test_httpresponse.rb
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue