diff --git a/lib/puma/server.rb b/lib/puma/server.rb index c9786dd6..90a17101 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -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 diff --git a/test/test_persistent.rb b/test/test_persistent.rb index eb455f3d..3317ddd8 100644 --- a/test/test_persistent.rb +++ b/test/test_persistent.rb @@ -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