Skip to content

Commit

Permalink
Add test_client_quick_close_no_lowlevel_error_handler_call
Browse files Browse the repository at this point in the history
See puma#2390

Fixed by puma#2279

Fails in 5.0.2
  • Loading branch information
MSP-Greg committed Oct 15, 2020
1 parent 54f6911 commit e415784
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/test_puma_server.rb
Expand Up @@ -1103,4 +1103,41 @@ def test_accept_econnaborted
stub_accept_nonblock(error)
assert_empty @events.stderr.string
end

# see https://github.com/puma/puma/issues/2390
# fixed by https://github.com/puma/puma/pull/2279
#
def test_client_quick_close_no_lowlevel_error_handler_call
handler = ->(err, env, status) {
@events.stdout.write "LLEH #{err.message}"
[500, {"Content-Type" => "application/json"}, ["{}\n"]]
}

@server = Puma::Server.new @app, @events, {:lowlevel_error_handler => handler}

server_run app: ->(env) { [200, {}, ['Hello World']] }

# valid req & read, close
sock = TCPSocket.new @host, @port
sock.syswrite "GET / HTTP/1.0\r\n\r\n"
resp = sock.sysread 256
sock.close
assert_match 'Hello World', resp
sleep 0.5
assert_empty @events.stdout.string

# valid req, close
sock = TCPSocket.new @host, @port
sock.syswrite "GET / HTTP/1.0\r\n\r\n"
sock.close
sleep 0.5
assert_empty @events.stdout.string

# invalid req, close
sock = TCPSocket.new @host, @port
sock.syswrite "GET / HTTP"
sock.close
sleep 0.5
assert_empty @events.stdout.string
end
end

0 comments on commit e415784

Please sign in to comment.