From 3273109cbe67aa4431d4507ba58dcb153c03773e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 22 May 2019 17:58:34 +0200 Subject: [PATCH] [HttpClient] display proper error message on TransportException when curl is used --- .../Component/HttpClient/Exception/HttpExceptionTrait.php | 4 ++-- src/Symfony/Component/HttpClient/Response/CurlResponse.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php b/src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php index 3278af9be0..76e650934b 100644 --- a/src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php +++ b/src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php @@ -27,7 +27,7 @@ trait HttpExceptionTrait $this->response = $response; $code = $response->getInfo('http_code'); $url = $response->getInfo('url'); - $message = sprintf('HTTP %d returned for URL "%s".', $code, $url); + $message = sprintf('HTTP %d returned for "%s".', $code, $url); $httpCodeFound = false; $isJson = false; @@ -37,7 +37,7 @@ trait HttpExceptionTrait break; } - $message = sprintf('%s returned for URL "%s".', $h, $url); + $message = sprintf('%s returned for "%s".', $h, $url); $httpCodeFound = true; } diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 2a4cd5546a..a54ab6dc20 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -245,7 +245,7 @@ final class CurlResponse implements ResponseInterface while ($info = curl_multi_info_read($multi->handle)) { $multi->handlesActivity[(int) $info['handle']][] = null; - $multi->handlesActivity[(int) $info['handle']][] = \in_array($info['result'], [\CURLE_OK, \CURLE_TOO_MANY_REDIRECTS], true) || (\CURLE_WRITE_ERROR === $info['result'] && 'destruct' === @curl_getinfo($info['handle'], CURLINFO_PRIVATE)) ? null : new TransportException(curl_error($info['handle'])); + $multi->handlesActivity[(int) $info['handle']][] = \in_array($info['result'], [\CURLE_OK, \CURLE_TOO_MANY_REDIRECTS], true) || (\CURLE_WRITE_ERROR === $info['result'] && 'destruct' === @curl_getinfo($info['handle'], CURLINFO_PRIVATE)) ? null : new TransportException(sprintf('%s for"%s".', curl_strerror($info['result']), curl_getinfo($info['handle'], CURLINFO_EFFECTIVE_URL))); } } finally { self::$performing = false;