Skip to content

Commit

Permalink
Fewer socket write with Enum chunked body
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg committed Feb 3, 2023
1 parent 733305b commit 4f65649
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/puma/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,15 @@ def fast_write_response(socket, body, io_buffer, chunked, content_length)
fast_write_str(socket, io_buffer.read_and_reset) unless io_buffer.length.zero?
else
# for enum bodies
fast_write_str socket, io_buffer.read_and_reset
if chunked
body.each do |part|
next if (byte_size = part.bytesize).zero?
fast_write_str socket, (byte_size.to_s(16) << LINE_END)
fast_write_str socket, part
fast_write_str socket, LINE_END
io_buffer.append byte_size.to_s(16), LINE_END, part, LINE_END
fast_write_str socket, io_buffer.read_and_reset
end
fast_write_str socket, CLOSE_CHUNKED
else
fast_write_str socket, io_buffer.read_and_reset
body.each do |part|
next if part.bytesize.zero?
fast_write_str socket, part
Expand Down

0 comments on commit 4f65649

Please sign in to comment.