Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
multiline response message header support.
closes nahi#16.
  • Loading branch information
nahi committed Oct 30, 2009
1 parent cc37a7f commit 7968719
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 9 additions & 3 deletions lib/httpclient/session.rb
Expand Up @@ -768,9 +768,15 @@ def parse_header
end
line.chomp!
break if line.empty?
key, value = line.split(/\s*:\s*/, 2)
parse_keepalive_header(key, value)
@headers << [key, value]
if line[0] == ?\ or line[0] == ?\t
last = @headers.last[1]
last << ' ' unless last.empty?
last << line.strip
else
key, value = line.strip.split(/\s*:\s*/, 2)
parse_keepalive_header(key, value)
@headers << [key, value]
end
end
end while (@version == '1.1' && @status == 100)
end
Expand Down
11 changes: 10 additions & 1 deletion test/test_httpclient.rb
Expand Up @@ -345,9 +345,18 @@ def test_loopback_http_response
assert_equal('message body 2', @client.get_content('http://somewhere'))
end

def test_multiline_header
@client.test_loopback_http_response << "HTTP/1.0 200 OK\nX-Foo: XXX\n YYY\nX-Bar: \n XXX\n\tYYY\ncontent-length: 100\n\nmessage body 1"
res = @client.get('http://somewhere')
assert_equal('message body 1', res.content)
assert_equal(['XXX YYY'], res.header['x-foo'])
assert_equal(['XXX YYY'], res.header['x-bar'])
end

def test_broken_header
@client.test_loopback_http_response << "HTTP/1.0 200 OK\nXXXXX\ncontent-length: 100\n\nmessage body 1"
assert_equal('message body 1', @client.get_content('http://somewhere'))
res = @client.get('http://somewhere')
assert_equal('message body 1', res.content)
end

def test_redirect_non_https
Expand Down

0 comments on commit 7968719

Please sign in to comment.