Skip to content

Commit

Permalink
Send 408 request timeout even when queue requests is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
wjordan committed Feb 20, 2020
1 parent 71bcd84 commit e47121c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -10,6 +10,7 @@
* Bugfixes
* Your bugfix goes here (#Github Number)
* Windows update extconf.rb for use with ssp and varied Ruby/MSYS2 combinations (#2069)
* Send 408 request timeout even when queue requests is disabled (#2119)

* Refactor
* Remove unused loader argument from Plugin initializer (#2095)
Expand Down
7 changes: 5 additions & 2 deletions lib/puma/client.rb
Expand Up @@ -243,10 +243,13 @@ def eagerly_finish
send(:alias_method, :jruby_eagerly_finish, :eagerly_finish)
end # IS_JRUBY

def finish
def finish(timeout)
return true if @ready
until try_to_finish
IO.select([@to_io], nil, nil)
unless IO.select([@to_io], nil, nil, timeout)
write_error(408) if in_data_phase
raise ConnectionError
end
end
true
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puma/server.rb
Expand Up @@ -308,7 +308,7 @@ def run(background=true)
if queue_requests
process_now = client.eagerly_finish
else
client.finish
client.finish(@first_data_timeout)
process_now = true
end
rescue MiniSSL::SSLError => e
Expand Down
5 changes: 5 additions & 0 deletions test/test_puma_server.rb
Expand Up @@ -336,6 +336,11 @@ def test_timeout_in_data_phase
assert_equal "HTTP/1.1 408 Request Timeout\r\n", data
end

def test_timeout_data_no_queue
@server = Puma::Server.new @app, @events, queue_requests: false
test_timeout_in_data_phase
end

def test_http_11_keep_alive_with_body
server_run app: ->(env) { [200, {"Content-Type" => "plain/text"}, ["hello\n"]] }

Expand Down

0 comments on commit e47121c

Please sign in to comment.