diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 02236b466b..a99bfff2e8 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -225,7 +225,6 @@ final class CurlResponse implements ResponseInterface */ private function close(): void { - $this->inflate = null; unset($this->multi->openHandles[$this->id], $this->multi->handlesActivity[$this->id]); curl_setopt($this->handle, \CURLOPT_PRIVATE, '_0'); diff --git a/src/Symfony/Component/HttpClient/Response/NativeResponse.php b/src/Symfony/Component/HttpClient/Response/NativeResponse.php index 402210f53e..41eadf1a41 100644 --- a/src/Symfony/Component/HttpClient/Response/NativeResponse.php +++ b/src/Symfony/Component/HttpClient/Response/NativeResponse.php @@ -193,7 +193,7 @@ final class NativeResponse implements ResponseInterface private function close(): void { unset($this->multi->openHandles[$this->id], $this->multi->handlesActivity[$this->id]); - $this->handle = $this->buffer = $this->inflate = $this->onProgress = null; + $this->handle = $this->buffer = $this->onProgress = null; } /** diff --git a/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php b/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php index 32a005f404..ed9d4e4045 100644 --- a/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php +++ b/src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php @@ -63,6 +63,12 @@ switch ($vars['REQUEST_URI']) { header('Content-Type: application/json', true, 404); break; + case '/404-gzipped': + header('Content-Type: text/plain', true, 404); + ob_start('ob_gzhandler'); + echo 'some text'; + exit; + case '/301': if ('Basic Zm9vOmJhcg==' === $vars['HTTP_AUTHORIZATION']) { header('Location: http://127.0.0.1:8057/302', true, 301); diff --git a/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php b/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php index 839965df79..f3e75c9337 100644 --- a/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php +++ b/src/Symfony/Contracts/HttpClient/Test/HttpClientTestCase.php @@ -835,6 +835,18 @@ abstract class HttpClientTestCase extends TestCase } } + public function testGetEncodedContentAfterDestruct() + { + $client = $this->getHttpClient(__FUNCTION__); + + try { + $client->request('GET', 'http://localhost:8057/404-gzipped'); + $this->fail(ClientExceptionInterface::class.' expected'); + } catch (ClientExceptionInterface $e) { + $this->assertSame('some text', $e->getResponse()->getContent(false)); + } + } + public function testProxy() { $client = $this->getHttpClient(__FUNCTION__);