Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Commit

Permalink
Adding curl error string. Closes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed May 21, 2015
1 parent dbbb91d commit 9465032
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/Client/CurlMultiHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ private function processMessages()

if ($done['result'] !== CURLM_OK) {
$entry['response']['curl']['errno'] = $done['result'];
if (function_exists('curl_strerror')) {
$entry['response']['curl']['error'] = curl_strerror($done['result']);
}
$entry['response']['curl']['error'] = curl_error($done['handle']);
}

$result = CurlFactory::createResponse(
Expand Down
16 changes: 16 additions & 0 deletions tests/Client/CurlMultiHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,20 @@ public function testSendsNonLazyFutures()
$this->assertInstanceOf('GuzzleHttp\Ring\Future\FutureArray', $response);
$this->assertEquals(202, $response['status']);
}

public function testExtractsErrors()
{
$request = [
'http_method' => 'GET',
'headers' => ['host' => ['127.0.0.1:123']],
'future' => true,
];
Server::flush();
Server::enqueue([['status' => 202]]);
$a = new CurlMultiHandler();
$response = $a($request);
$this->assertInstanceOf('GuzzleHttp\Ring\Future\FutureArray', $response);
$this->assertEquals(CURLE_COULDNT_CONNECT, $response['curl']['errno']);
$this->assertNotEmpty($response['curl']['error']);
}
}

0 comments on commit 9465032

Please sign in to comment.