1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Make sure that the chunk is specified in hex, not dec

This commit is contained in:
Evan Phoenix 2011-09-30 11:05:44 -05:00
parent 9f5df5d77d
commit 89ea73cee5
2 changed files with 12 additions and 2 deletions

View file

@ -263,7 +263,7 @@ module Puma
if res_body.kind_of? String
if chunked
client.write res_body.size.to_s
client.write res_body.size.to_s(16)
client.write line_ending
client.write res_body
client.write line_ending
@ -275,7 +275,7 @@ module Puma
else
res_body.each do |part|
if chunked
client.write part.size.to_s
client.write part.size.to_s(16)
client.write line_ending
client.write part
client.write line_ending

View file

@ -55,4 +55,14 @@ class TestPersistent < Test::Unit::TestCase
assert_equal "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nX-Header: Works\r\n\r\n5\r\nHello\r\n7\r\nChunked\r\n0\r\n", lines(9)
end
def test_hex
str = "This is longer and will be in hex"
@body << str
@client << @valid_request
assert_equal "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nX-Header: Works\r\n\r\n5\r\nHello\r\n#{str.size.to_s(16)}\r\n#{str}\r\n0\r\n", lines(9)
end
end