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

Add support for streaming bodies. (#2740)

* Add support for streaming bodies.

* Added a test

Co-authored-by: Nate Berkopec <nate.berkopec@gmail.com>
This commit is contained in:
Samuel Williams 2022-01-30 06:15:36 +13:00 committed by GitHub
parent 0a149ecf61
commit a63c0faf33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View file

@ -116,7 +116,11 @@ module Puma
line_ending = LINE_END
content_length = res_info[:content_length]
response_hijack = res_info[:response_hijack]
if res_body && !res_body.respond_to?(:each)
response_hijack = res_body
else
response_hijack = res_info[:response_hijack]
end
if res_info[:no_body]
if content_length and status != 204

View file

@ -116,6 +116,21 @@ class TestPumaServer < Minitest::Test
assert_equal "[::1]\n80", data.split("\r\n").last
end
def test_streaming_body
server_run do |env|
body = lambda do |stream|
stream.write("Hello World")
stream.close
end
[200, {}, body]
end
data = send_http_and_read "GET / HTTP/1.0\r\nConnection: close\r\n\r\n"
assert_equal "Hello World", data.split("\n").last
end
def test_proper_stringio_body
data = nil