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:
parent
0a149ecf61
commit
a63c0faf33
2 changed files with 20 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue