diff --git a/test/test_puma_server.rb b/test/test_puma_server.rb index 33347bf0..d87a9e31 100644 --- a/test/test_puma_server.rb +++ b/test/test_puma_server.rb @@ -1257,12 +1257,12 @@ def test_chunked_keep_alive_two_back_to_back end def test_chunked_keep_alive_twenty_back_to_back - skip if :windows + req_count = 20 requests = 0 body = nil content_length = nil - server_run { |env| + server_run(max_fast_inline: 21) { |env| requests += 1 body = env['rack.input'].read content_length = env['CONTENT_LENGTH'] @@ -1271,11 +1271,20 @@ def test_chunked_keep_alive_twenty_back_to_back req = "GET / HTTP/1.1\r\nX-Forwarded-For: 127.0.0.1\r\nConnection: Keep-Alive\r\nTransfer-Encoding: chunked\r\n\r\n1\r\nh\r\n4\r\nello\r\n0\r\n\r\n" - socket = send_http(req * 20) - - 20.times do |i| - assert_equal "Request_#{i+1}", socket.read_body + expected = String.new # rubocop: disable Performance/UnfreezeString + req_count.times do |i| + expected << "HTTP/1.1 200 OK\r\nContent-Length: #{(i+1).to_s.length + 8}\r\n\r\nRequest_#{i+1}" end + + socket = send_http(req * req_count) + Thread.pass + sleep 0.2 + + sent = socket.read + + assert_equal req_count, sent.scan('Request_').length + + assert_equal expected, sent end def test_chunked_keep_alive_two_back_to_back_with_set_remote_address