From d4cde319404b64b9f4506eb1191b2a6434383e6f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 12 Mar 2020 15:38:01 +0100 Subject: [PATCH] [HttpClient] disable debug log with curl 7.64.0 --- src/Symfony/Component/HttpClient/CurlHttpClient.php | 2 +- .../Component/HttpClient/Response/CurlResponse.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpClient/CurlHttpClient.php b/src/Symfony/Component/HttpClient/CurlHttpClient.php index b076e9a7b520..b037ca0fc29e 100644 --- a/src/Symfony/Component/HttpClient/CurlHttpClient.php +++ b/src/Symfony/Component/HttpClient/CurlHttpClient.php @@ -308,7 +308,7 @@ public function request(string $method, string $url, array $options = []): Respo } } - return $pushedResponse ?? new CurlResponse($this->multi, $ch, $options, $this->logger, $method, self::createRedirectResolver($options, $host)); + return $pushedResponse ?? new CurlResponse($this->multi, $ch, $options, $this->logger, $method, self::createRedirectResolver($options, $host), self::$curlVersion['version_number']); } /** diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 0a6597fb0852..58528108e8d1 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -37,15 +37,19 @@ final class CurlResponse implements ResponseInterface /** * @internal */ - public function __construct(CurlClientState $multi, $ch, array $options = null, LoggerInterface $logger = null, string $method = 'GET', callable $resolveRedirect = null) + public function __construct(CurlClientState $multi, $ch, array $options = null, LoggerInterface $logger = null, string $method = 'GET', callable $resolveRedirect = null, int $curlVersion = null) { $this->multi = $multi; if (\is_resource($ch)) { $this->handle = $ch; $this->debugBuffer = fopen('php://temp', 'w+'); - curl_setopt($ch, CURLOPT_VERBOSE, true); - curl_setopt($ch, CURLOPT_STDERR, $this->debugBuffer); + if (0x074000 === $curlVersion) { + fwrite($this->debugBuffer, 'Due to a bug in curl 7.64.0, the debug log is disabled; use another version to work around the issue.'); + } else { + curl_setopt($ch, CURLOPT_VERBOSE, true); + curl_setopt($ch, CURLOPT_STDERR, $this->debugBuffer); + } } else { $this->info['url'] = $ch; $ch = $this->handle;