mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Merge pull request #711 from julik/master
Do not suppress Content-Length on partial hijack (fixes #710)
This commit is contained in:
commit
4f94a549c2
2 changed files with 30 additions and 9 deletions
|
@ -639,15 +639,13 @@ module Puma
|
|||
fast_write client, lines.to_s
|
||||
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
|
||||
|
|
|
@ -369,7 +369,30 @@ 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