From 106eb56abbdd2a7c3d205c60640605deb5f31b8d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 9 Oct 2020 15:47:20 +0200 Subject: [PATCH] Fix HEAD requests with `accept-encoding` header set This backports the change in guzzle/guzzle#2804. --- .../files/lib/system/api/composer.lock | 8 ++-- .../lib/system/api/composer/installed.json | 8 ++-- .../guzzle/src/Handler/CurlFactory.php | 43 +++++++++---------- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/wcfsetup/install/files/lib/system/api/composer.lock b/wcfsetup/install/files/lib/system/api/composer.lock index 399dc02aec..86b3664373 100644 --- a/wcfsetup/install/files/lib/system/api/composer.lock +++ b/wcfsetup/install/files/lib/system/api/composer.lock @@ -148,12 +148,12 @@ "source": { "type": "git", "url": "https://github.com/WoltLab/guzzle", - "reference": "2d4592a12d3d6757f9969122730e69d6b7c82af0" + "reference": "40e0ba7d933ec47237adb4f35ba363c3d8ffe453" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WoltLab/guzzle/zipball/2d4592a12d3d6757f9969122730e69d6b7c82af0", - "reference": "2d4592a12d3d6757f9969122730e69d6b7c82af0", + "url": "https://api.github.com/repos/WoltLab/guzzle/zipball/40e0ba7d933ec47237adb4f35ba363c3d8ffe453", + "reference": "40e0ba7d933ec47237adb4f35ba363c3d8ffe453", "shasum": "" }, "require": { @@ -211,7 +211,7 @@ "rest", "web service" ], - "time": "2020-09-30T10:06:20+00:00" + "time": "2020-10-09T13:06:06+00:00" }, { "name": "guzzlehttp/promises", diff --git a/wcfsetup/install/files/lib/system/api/composer/installed.json b/wcfsetup/install/files/lib/system/api/composer/installed.json index 0cc5f5690e..9b678851b0 100644 --- a/wcfsetup/install/files/lib/system/api/composer/installed.json +++ b/wcfsetup/install/files/lib/system/api/composer/installed.json @@ -148,12 +148,12 @@ "source": { "type": "git", "url": "https://github.com/WoltLab/guzzle", - "reference": "2d4592a12d3d6757f9969122730e69d6b7c82af0" + "reference": "40e0ba7d933ec47237adb4f35ba363c3d8ffe453" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WoltLab/guzzle/zipball/2d4592a12d3d6757f9969122730e69d6b7c82af0", - "reference": "2d4592a12d3d6757f9969122730e69d6b7c82af0", + "url": "https://api.github.com/repos/WoltLab/guzzle/zipball/40e0ba7d933ec47237adb4f35ba363c3d8ffe453", + "reference": "40e0ba7d933ec47237adb4f35ba363c3d8ffe453", "shasum": "" }, "require": { @@ -171,7 +171,7 @@ "suggest": { "psr/log": "Required for using the Log middleware" }, - "time": "2020-09-30T10:06:20+00:00", + "time": "2020-10-09T13:06:06+00:00", "type": "library", "extra": { "branch-alias": { diff --git a/wcfsetup/install/files/lib/system/api/guzzlehttp/guzzle/src/Handler/CurlFactory.php b/wcfsetup/install/files/lib/system/api/guzzlehttp/guzzle/src/Handler/CurlFactory.php index 48d909383c..4bcbb35ade 100644 --- a/wcfsetup/install/files/lib/system/api/guzzlehttp/guzzle/src/Handler/CurlFactory.php +++ b/wcfsetup/install/files/lib/system/api/guzzlehttp/guzzle/src/Handler/CurlFactory.php @@ -375,30 +375,27 @@ class CurlFactory implements CurlFactoryInterface } } - // Do not connect a sink for HEAD requests. - if ($easy->request->getMethod() !== 'HEAD') { - if (!isset($options['sink'])) { - // Use a default temp stream if no sink was set. - $options['sink'] = \fopen('php://temp', 'w+'); - } - $sink = $options['sink']; - if (!is_string($sink)) { - $sink = \GuzzleHttp\Psr7\stream_for($sink); - } elseif (!is_dir(dirname($sink))) { - // Ensure that the directory exists before failing in curl. - throw new \RuntimeException(sprintf( - 'Directory %s does not exist for sink value of %s', - dirname($sink), - $sink - )); - } else { - $sink = new LazyOpenStream($sink, 'w+'); - } - $easy->sink = $sink; - $conf[CURLOPT_WRITEFUNCTION] = function ($ch, $write) use ($sink) { - return $sink->write($write); - }; + if (!isset($options['sink'])) { + // Use a default temp stream if no sink was set. + $options['sink'] = \fopen('php://temp', 'w+'); + } + $sink = $options['sink']; + if (!is_string($sink)) { + $sink = \GuzzleHttp\Psr7\stream_for($sink); + } elseif (!is_dir(dirname($sink))) { + // Ensure that the directory exists before failing in curl. + throw new \RuntimeException(sprintf( + 'Directory %s does not exist for sink value of %s', + dirname($sink), + $sink + )); + } else { + $sink = new LazyOpenStream($sink, 'w+'); } + $easy->sink = $sink; + $conf[CURLOPT_WRITEFUNCTION] = function ($ch, $write) use ($sink) { + return $sink->write($write); + }; $timeoutRequiresNoSignal = false; if (isset($options['timeout'])) { -- 2.20.1