summaryrefslogtreecommitdiffstats
path: root/lib
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 /lib
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 'lib')
-rw-r--r--lib/net/http.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 64dbef4cb..57a2b2eea 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -2158,13 +2158,20 @@ module Net #:nodoc:
end
def each_response_header(sock)
+ key = value = nil
while true
line = sock.readuntil("\n", true).sub(/\s+\z/, '')
break if line.empty?
- m = /\A([^:]+):\s*/.match(line) or
- raise HTTPBadResponse, 'wrong header line format'
- yield m[1], m.post_match
+ if line[0] == ?\ or line[0] == ?\t and value
+ value << ' ' unless value.empty?
+ value << line.strip
+ else
+ yield key, value if key
+ key, value = line.strip.split(/\s*:\s*/, 2)
+ raise HTTPBadResponse, 'wrong header line format' if value.nil?
+ end
end
+ yield key, value if key
end
end