From afffbd5c9127a6a456a8d62795520f8c826ace64 Mon Sep 17 00:00:00 2001 From: Mirco Babini Date: Mon, 6 Dec 2021 17:56:10 +0100 Subject: [PATCH 1/3] Add Connection:close header only when needed --- src/Transport/Curl.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Transport/Curl.php b/src/Transport/Curl.php index 289d9b15b..55b200c5f 100644 --- a/src/Transport/Curl.php +++ b/src/Transport/Curl.php @@ -25,6 +25,7 @@ final class Curl implements Transport { const CURL_7_10_5 = 0x070A05; const CURL_7_16_2 = 0x071002; + const CURL_7_22_0 = 0x071600; /** * Raw HTTP data @@ -363,8 +364,10 @@ private function setup_handle($url, $headers, $data, $options) { $options['hooks']->dispatch('curl.before_request', [&$this->handle]); // Force closing the connection for old versions of cURL (<7.22). - if (!isset($headers['Connection'])) { - $headers['Connection'] = 'close'; + if ($this->version < self::CURL_7_22_0) { + if (!isset($headers['Connection'])) { + $headers['Connection'] = 'close'; + } } /** From 16cd384214e6ba201da18b126fe78d39540487c6 Mon Sep 17 00:00:00 2001 From: Mirco Babini Date: Sat, 26 Feb 2022 17:15:28 +0100 Subject: [PATCH 2/3] Update src/Transport/Curl.php Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- src/Transport/Curl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Transport/Curl.php b/src/Transport/Curl.php index 55b200c5f..7b6d99b85 100644 --- a/src/Transport/Curl.php +++ b/src/Transport/Curl.php @@ -364,8 +364,7 @@ private function setup_handle($url, $headers, $data, $options) { $options['hooks']->dispatch('curl.before_request', [&$this->handle]); // Force closing the connection for old versions of cURL (<7.22). - if ($this->version < self::CURL_7_22_0) { - if (!isset($headers['Connection'])) { + if ($this->version < self::CURL_7_22_0 && !isset($headers['Connection'])) { $headers['Connection'] = 'close'; } } From daf8a046c7b9c6317148ce905ac7f7d3c082effa Mon Sep 17 00:00:00 2001 From: Mirco Babini Date: Thu, 17 Aug 2023 14:54:04 +0200 Subject: [PATCH 3/3] Update src/Transport/Curl.php Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- src/Transport/Curl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Transport/Curl.php b/src/Transport/Curl.php index 7b6d99b85..9a9f03f93 100644 --- a/src/Transport/Curl.php +++ b/src/Transport/Curl.php @@ -365,8 +365,7 @@ private function setup_handle($url, $headers, $data, $options) { // Force closing the connection for old versions of cURL (<7.22). if ($this->version < self::CURL_7_22_0 && !isset($headers['Connection'])) { - $headers['Connection'] = 'close'; - } + $headers['Connection'] = 'close'; } /**