mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-24 10:03:27 +01:00
Merge pull request #2108 from wwulfric/master
curl error msg for low version
This commit is contained in:
commit
3d499a1b7c
@ -14,6 +14,9 @@ use Psr\Http\Message\RequestInterface;
|
|||||||
*/
|
*/
|
||||||
class CurlFactory implements CurlFactoryInterface
|
class CurlFactory implements CurlFactoryInterface
|
||||||
{
|
{
|
||||||
|
const CURL_VERSION_STR = 'curl_version';
|
||||||
|
const LOW_CURL_VERSION_NUMBER = '7.21.2';
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
private $handles = [];
|
private $handles = [];
|
||||||
|
|
||||||
@ -137,6 +140,7 @@ class CurlFactory implements CurlFactoryInterface
|
|||||||
'errno' => $easy->errno,
|
'errno' => $easy->errno,
|
||||||
'error' => curl_error($easy->handle),
|
'error' => curl_error($easy->handle),
|
||||||
] + curl_getinfo($easy->handle);
|
] + curl_getinfo($easy->handle);
|
||||||
|
$ctx[self::CURL_VERSION_STR] = curl_version()['version'];
|
||||||
$factory->release($easy);
|
$factory->release($easy);
|
||||||
|
|
||||||
// Retry when nothing is present or when curl failed to rewind.
|
// Retry when nothing is present or when curl failed to rewind.
|
||||||
@ -172,13 +176,22 @@ class CurlFactory implements CurlFactoryInterface
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (version_compare($ctx[self::CURL_VERSION_STR], self::LOW_CURL_VERSION_NUMBER)) {
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'cURL error %s: %s (%s)',
|
'cURL error %s: %s (%s)',
|
||||||
$ctx['errno'],
|
$ctx['errno'],
|
||||||
$ctx['error'],
|
$ctx['error'],
|
||||||
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html'
|
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html'
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$message = sprintf(
|
||||||
|
'cURL error %s: %s (%s) for %s',
|
||||||
|
$ctx['errno'],
|
||||||
|
$ctx['error'],
|
||||||
|
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html',
|
||||||
|
$easy->request->getUri()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Create a connection exception if it was a specific error code.
|
// Create a connection exception if it was a specific error code.
|
||||||
$error = isset($connectionErrors[$easy->errno])
|
$error = isset($connectionErrors[$easy->errno])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user