From 8fc08854e07ce9fc83a0c9f3ea5d8d4e118fe952 Mon Sep 17 00:00:00 2001 From: thomas morgan Date: Thu, 7 Sep 2023 11:37:24 -0600 Subject: [PATCH] prefer close over keep-alive when both present --- lib/protocol/http/header/connection.rb | 2 +- test/protocol/http/header/connection.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/protocol/http/header/connection.rb b/lib/protocol/http/header/connection.rb index 33a8246..ceab81c 100644 --- a/lib/protocol/http/header/connection.rb +++ b/lib/protocol/http/header/connection.rb @@ -22,7 +22,7 @@ def << value end def keep_alive? - self.include?(KEEP_ALIVE) + self.include?(KEEP_ALIVE) && !close? end def close? diff --git a/test/protocol/http/header/connection.rb b/test/protocol/http/header/connection.rb index 5ea6c23..55956e6 100644 --- a/test/protocol/http/header/connection.rb +++ b/test/protocol/http/header/connection.rb @@ -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?)