Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 89ea73cee53c307750f36cb5dc9936796e4a466b 1 parent 9f5df5d
@evanphx evanphx authored
Showing with 12 additions and 2 deletions.
  1. +2 −2 lib/puma/server.rb
  2. +10 −0 test/test_persistent.rb
View
4 lib/puma/server.rb
@@ -263,7 +263,7 @@ def handle_request(env, client, body)
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 @@ def handle_request(env, client, body)
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
10 test/test_persistent.rb
@@ -55,4 +55,14 @@ def test_chunked
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
Please sign in to comment.
Something went wrong with that request. Please try again.