1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Close connection in web server tests (#2072)

[skip changelog]

Closes #2049

Before this commit, `test_trickle_attack` and
`test_file_streamed_request` were each taking an extra 20 seconds to run.

Without the `Connection: close` header, the [connection was kept
alive][keep alive] until it timed out after the
[`PERSISTENT_TIMEOUT`][PERSISTENT_TIMEOUT] duration of 20 seconds.

[keep alive]: 3835ac74de/lib/puma/server.rb (L706-L708)
[PERSISTENT_TIMEOUT]: 3835ac74de/lib/puma/const.rb (L109-L111)
This commit is contained in:
Daniel Colson 2019-11-11 18:56:45 -05:00 committed by Nate Berkopec
parent 3835ac74de
commit fcb99b91cc

View file

@ -19,7 +19,7 @@ end
class WebServerTest < Minitest::Test
parallelize_me!
VALID_REQUEST = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\n\r\n"
VALID_REQUEST = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\nConnection: close\r\n\r\n"
def setup
@tester = TestHandler.new
@ -63,10 +63,9 @@ class WebServerTest < Minitest::Test
end
end
# TODO: Why does this test take exactly 20 seconds?
def test_file_streamed_request
body = "a" * (Puma::Const::MAX_BODY * 2)
long = "GET /test HTTP/1.1\r\nContent-length: #{body.length}\r\n\r\n" + body
long = "GET /test HTTP/1.1\r\nContent-length: #{body.length}\r\nConnection: close\r\n\r\n" + body
socket = do_test(long, (Puma::Const::CHUNK_SIZE * 2) - 400)
assert_match "hello", socket.read
socket.close