aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
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 64dbef4cbb..57a2b2eea5 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