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

View file

@ -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

View file

@ -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, {}, []] }