mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Merge branch 'master' of github.com:puma/puma
This commit is contained in:
commit
0d4016a999
2 changed files with 30 additions and 9 deletions
|
@ -640,14 +640,12 @@ module Puma
|
|||
return keep_alive
|
||||
end
|
||||
|
||||
unless response_hijack
|
||||
if content_length
|
||||
lines.append CONTENT_LENGTH_S, content_length.to_s, line_ending
|
||||
chunked = false
|
||||
elsif allow_chunked
|
||||
lines << TRANSFER_ENCODING_CHUNKED
|
||||
chunked = true
|
||||
end
|
||||
if content_length
|
||||
lines.append CONTENT_LENGTH_S, content_length.to_s, line_ending
|
||||
chunked = false
|
||||
elsif allow_chunked
|
||||
lines << TRANSFER_ENCODING_CHUNKED
|
||||
chunked = true
|
||||
end
|
||||
|
||||
lines << line_ending
|
||||
|
|
|
@ -370,6 +370,29 @@ class TestPumaServer < Test::Unit::TestCase
|
|||
assert_equal "HTTP/1.0 200 OK\r\nContent-Type: plain/text\r\nContent-Length: 5\r\n\r\nhello", data
|
||||
end
|
||||
|
||||
def test_http_10_partial_hijack_with_content_length
|
||||
body_parts = ['abc', 'de']
|
||||
|
||||
@server.app = proc do |env|
|
||||
hijack_lambda = proc do | io |
|
||||
io.write(body_parts[0])
|
||||
io.write(body_parts[1])
|
||||
io.close
|
||||
end
|
||||
[200, {"Content-Length" => "5", 'rack.hijack' => hijack_lambda}, nil]
|
||||
end
|
||||
|
||||
@server.add_tcp_listener @host, @port
|
||||
@server.run
|
||||
|
||||
sock = TCPSocket.new @host, @port
|
||||
sock << "GET / HTTP/1.0\r\nConnection: close\r\n\r\n"
|
||||
|
||||
data = sock.read
|
||||
|
||||
assert_equal "HTTP/1.0 200 OK\r\nContent-Length: 5\r\n\r\nabcde", data
|
||||
end
|
||||
|
||||
def test_http_10_keep_alive_without_body
|
||||
@server.app = proc { |env| [204, {}, []] }
|
||||
|
||||
|
|
Loading…
Reference in a new issue