1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-24 10:03:27 +01:00

Merge pull request #1143 from hussainweb/master

Support HHVM. See if CURLOPT_PROTOCOLS is defined before using it and other HHVM errors.
This commit is contained in:
Michael Dowling 2015-06-30 13:37:09 -07:00
commit 66737d2024
3 changed files with 8 additions and 5 deletions

View File

@ -117,9 +117,8 @@ class CurlFactory implements CurlFactoryInterface
) {
// Get error information and release the handle to the factory.
$ctx = [
'errno' => $easy->errno,
'error' => curl_error($easy->handle)
?: curl_strerror($easy->errno)
'errno' => $easy->errno,
'error' => curl_error($easy->handle),
] + curl_getinfo($easy->handle);
$factory->release($easy);
@ -181,9 +180,12 @@ class CurlFactory implements CurlFactoryInterface
CURLOPT_RETURNTRANSFER => false,
CURLOPT_HEADER => false,
CURLOPT_CONNECTTIMEOUT => 150,
CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
];
if (defined('CURLOPT_PROTOCOLS')) {
$conf[CURLOPT_PROTOCOLS] = CURLPROTO_HTTP | CURLPROTO_HTTPS;
}
$version = $easy->request->getProtocolVersion();
if ($version == 1.1) {
$conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;

View File

@ -45,6 +45,7 @@ class StreamHandler
// This list can probably get more comprehensive.
if (strpos($message, 'getaddrinfo') // DNS lookup failed
|| strpos($message, 'Connection refused')
|| strpos($message, "couldn't connect to host") // error on HHVM
) {
$e = new ConnectException($e->getMessage(), $request, $e);
}

View File

@ -65,7 +65,7 @@ class MockHandlerTest extends \PHPUnit_Framework_TestCase
public function testCanEnqueueCallables()
{
$r = new Response();
$fn = function ($r, $o) use ($r) { return $r; };
$fn = function ($req, $o) use ($r) { return $r; };
$mock = new MockHandler([$fn]);
$request = new Request('GET', 'http://example.com');
$p = $mock($request, ['foo' => 'bar']);