[HttpClient] display proper error message on TransportException when curl is used

This commit is contained in:
Nicolas Grekas 2019-05-22 17:58:34 +02:00
parent 1cd99eaaa8
commit 3273109cbe
2 changed files with 3 additions and 3 deletions

View File

@ -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;
}

View File

@ -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;