Skip to content

Commit

Permalink
Prefer connection close over keep-alive when both present. (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
zarqman authored Jan 26, 2024
1 parent c1f4cbb commit c5da014
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/protocol/http/header/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def << value
end

def keep_alive?
self.include?(KEEP_ALIVE)
self.include?(KEEP_ALIVE) && !close?
end

def close?
Expand Down
7 changes: 7 additions & 0 deletions test/protocol/http/header/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
end
end

with "close, keep-alive" do
it "should prioritize close over keep-alive" do
expect(header).to be(:close?)
expect(header).not.to be(:keep_alive?)
end
end

with "upgrade" do
it "should indiciate connection can be upgraded" do
expect(header).to be(:upgrade?)
Expand Down

0 comments on commit c5da014

Please sign in to comment.