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

Merge pull request #743 from matthewd/skip-empty-chunks

Skip empty parts when chunking
This commit is contained in:
Evan Phoenix 2015-07-17 17:14:51 -07:00
commit 7e5b788610
2 changed files with 10 additions and 0 deletions

View file

@ -663,6 +663,7 @@ module Puma
begin
res_body.each do |part|
if chunked
next if part.bytesize.zero?
fast_write client, part.bytesize.to_s(16)
fast_write client, line_ending
fast_write client, part

View file

@ -101,6 +101,15 @@ class TestPersistent < Test::Unit::TestCase
assert_equal "HTTP/1.1 200 OK\r\nX-Header: Works\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nHello\r\n7\r\nChunked\r\n0\r\n\r\n", lines(10)
end
def test_chunked_with_empty_part
@body << ""
@body << "Chunked"
@client << @valid_request
assert_equal "HTTP/1.1 200 OK\r\nX-Header: Works\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nHello\r\n7\r\nChunked\r\n0\r\n\r\n", lines(10)
end
def test_no_chunked_in_http10
@body << "Chunked"