mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Deal with multiple aritys in lowlevel_error
This commit is contained in:
parent
eede26a122
commit
bca2c99f30
2 changed files with 25 additions and 1 deletions
|
@ -804,7 +804,11 @@ module Puma
|
|||
#
|
||||
def lowlevel_error(e, env)
|
||||
if handler = @options[:lowlevel_error_handler]
|
||||
return handler.call(e, env)
|
||||
if handler.arity == 1
|
||||
return handler.call(e)
|
||||
else
|
||||
return handler.call(e, env)
|
||||
end
|
||||
end
|
||||
|
||||
if @leak_stack_on_error
|
||||
|
|
|
@ -215,6 +215,26 @@ class TestPumaServer < Test::Unit::TestCase
|
|||
assert_match(/HTTP\/1.0 302 Found/, data)
|
||||
end
|
||||
|
||||
def test_leh_gets_env_as_well
|
||||
@events = Puma::Events.strings
|
||||
re = lambda { |err,env|
|
||||
env['REQUEST_PATH'] || raise("where is env?")
|
||||
[302, {'Content-Type' => 'text', 'Location' => 'foo.html'}, ['302 found']]
|
||||
}
|
||||
|
||||
@server = Puma::Server.new @app, @events, {:lowlevel_error_handler => re}
|
||||
|
||||
@server.app = proc { |e| raise "don't leak me bro" }
|
||||
@server.add_tcp_listener @host, @port
|
||||
@server.run
|
||||
|
||||
sock = TCPSocket.new @host, @server.connected_port
|
||||
sock << "GET / HTTP/1.0\r\n\r\n"
|
||||
|
||||
data = sock.read
|
||||
assert_match(/HTTP\/1.0 302 Found/, data)
|
||||
end
|
||||
|
||||
def test_custom_http_codes_10
|
||||
@server.app = proc { |env| [449, {}, [""]] }
|
||||
|
||||
|
|
Loading…
Reference in a new issue