Skip to content

Commit

Permalink
PLAT-955: create separate transport error hook
Browse files Browse the repository at this point in the history
implementation for cURL using new exception class
  • Loading branch information
Christopher A. Stelma committed Feb 2, 2016
1 parent 77e6bed commit a434d5e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions library/Requests/Transport/cURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,23 @@ public function request_multiple($requests, $options) {
// Parse the finished requests before we start getting the new ones
foreach ($to_process as $key => $done) {
$options = $requests[$key]['options'];
$responses[$key] = $subrequests[$key]->process_response($subrequests[$key]->response_data, $options);
if (CURLE_OK !== $done['result']) {
//get error string for handle.
$reason = curl_error($done['handle']);
$exception = new Requests_Exception_Transport_cURL(
$reason,
Requests_Exception_Transport_cURL::EASY,
$done['handle'],
$done['result']
);
$responses[$key] = $exception;
$options['hooks']->dispatch('transport.internal.parse_error', array(&$responses[$key], $requests[$key]));
}
else {
$responses[$key] = $subrequests[$key]->process_response($subrequests[$key]->response_data, $options);

$options['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$key], $requests[$key]));
$options['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$key], $requests[$key]));
}

curl_multi_remove_handle($multihandle, $done['handle']);
curl_close($done['handle']);
Expand Down

0 comments on commit a434d5e

Please sign in to comment.