1
0
Fork 0
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:
Evan Phoenix 2015-06-10 11:21:17 -07:00
commit 4f94a549c2
2 changed files with 30 additions and 9 deletions

View file

@ -640,7 +640,6 @@ module Puma
return keep_alive return keep_alive
end end
unless response_hijack
if content_length if content_length
lines.append CONTENT_LENGTH_S, content_length.to_s, line_ending lines.append CONTENT_LENGTH_S, content_length.to_s, line_ending
chunked = false chunked = false
@ -648,7 +647,6 @@ module Puma
lines << TRANSFER_ENCODING_CHUNKED lines << TRANSFER_ENCODING_CHUNKED
chunked = true chunked = true
end end
end
lines << line_ending lines << line_ending

View file

@ -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 assert_equal "HTTP/1.0 200 OK\r\nContent-Type: plain/text\r\nContent-Length: 5\r\n\r\nhello", data
end 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 def test_http_10_keep_alive_without_body
@server.app = proc { |env| [204, {}, []] } @server.app = proc { |env| [204, {}, []] }