Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send 408 request timeout even when queue requests is disabled #2119

Merged
merged 1 commit into from Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -12,6 +12,7 @@
* Your bugfix goes here (#Github Number)
* Windows update extconf.rb for use with ssp and varied Ruby/MSYS2 combinations (#2069)
* Preserve `BUNDLE_GEMFILE` env var when using `prune_bundler` (#1893)
* 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