Skip to content

Commit f7761ed

Browse files
committed
prefer close over keep-alive when both present
1 parent 6c50b9a commit f7761ed

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/protocol/http/header/connection.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def << value
2222
end
2323

2424
def keep_alive?
25-
self.include?(KEEP_ALIVE)
25+
self.include?(KEEP_ALIVE) && !close?
2626
end
2727

2828
def close?

test/protocol/http/header/connection.rb

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
end
3030
end
3131

32+
with "close, keep-alive" do
33+
it "should prioritize close over keep-alive" do
34+
expect(header).to be(:close?)
35+
expect(header).not.to be(:keep_alive?)
36+
end
37+
end
38+
3239
with "upgrade" do
3340
it "should indiciate connection can be upgraded" do
3441
expect(header).to be(:upgrade?)

0 commit comments

Comments
 (0)