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
Set Connection: closed
when running without request queueing
#2216
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b4c38ba
Fix test requires
praboud-stripe 345e127
Refactor how the HTTP connection header is set
praboud-stripe 6346bfe
Fix Connection header when not using queue_requests
praboud-stripe 8901a77
History
praboud-stripe 5d18d1c
Re-roll CI builds
praboud-stripe dd9825b
Rebuild again
praboud-stripe File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
require_relative "helper" | ||
require "puma/events" | ||
require "net/http" | ||
|
||
class TestPumaServer < Minitest::Test | ||
parallelize_me! | ||
|
@@ -880,4 +882,43 @@ def assert_does_not_allow_http_injection(app, opts = {}) | |
assert_does_not_allow_http_injection(app) | ||
end | ||
end | ||
|
||
def test_http11_connection_header_queue | ||
server_run app: ->(_) { [200, {}, [""]] } | ||
|
||
sock = send_http "GET / HTTP/1.1\r\n\r\n" | ||
assert_equal ["HTTP/1.1 200 OK", "Content-Length: 0"], header(sock) | ||
|
||
sock << "GET / HTTP/1.1\r\nConnection: close\r\n\r\n" | ||
assert_equal ["HTTP/1.1 200 OK", "Connection: close", "Content-Length: 0"], header(sock) | ||
|
||
sock.close | ||
end | ||
|
||
def test_http10_connection_header_queue | ||
server_run app: ->(_) { [200, {}, [""]] } | ||
|
||
sock = send_http "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n" | ||
assert_equal ["HTTP/1.0 200 OK", "Connection: Keep-Alive", "Content-Length: 0"], header(sock) | ||
|
||
sock << "GET / HTTP/1.0\r\n\r\n" | ||
assert_equal ["HTTP/1.0 200 OK", "Content-Length: 0"], header(sock) | ||
sock.close | ||
end | ||
|
||
def test_http11_connection_header_no_queue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test fails before the bugfix - the other 3 worked before and are just to ensure no regressions / generally exercise this code. |
||
@server = Puma::Server.new @app, @events, queue_requests: false | ||
server_run app: ->(_) { [200, {}, [""]] } | ||
sock = send_http "GET / HTTP/1.1\r\n\r\n" | ||
assert_equal ["HTTP/1.1 200 OK", "Connection: close", "Content-Length: 0"], header(sock) | ||
sock.close | ||
end | ||
|
||
def test_http10_connection_header_no_queue | ||
@server = Puma::Server.new @app, @events, queue_requests: false | ||
server_run app: ->(_) { [200, {}, [""]] } | ||
sock = send_http "GET / HTTP/1.0\r\n\r\n" | ||
assert_equal ["HTTP/1.0 200 OK", "Content-Length: 0"], header(sock) | ||
sock.close | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is conceptually unrelated to the rest of the change, but this test file needs these includes to run individually.