protected function CurlMulti::processResponse

Check for errors and fix headers of a request based on a curl response

Parameters

RequestInterface $request Request to process:

CurlHandle $handle Curl handle object:

array $curl Array returned from curl_multi_info_read:

Throws

CurlException on Curl error

1 call to CurlMulti::processResponse()
CurlMulti::processMessages in drupal/core/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php
Process any received curl multi messages

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php, line 521

Class

CurlMulti
Send { This implementation allows callers to send blocking requests that return back to the caller when their requests complete, regardless of whether or not previously sending requests in the curl_multi object have completed. The implementation…

Namespace

Guzzle\Http\Curl

Code

protected function processResponse(RequestInterface $request, CurlHandle $handle, array $curl) {

  // Set the transfer stats on the response
  $handle
    ->updateRequestFromTransfer($request);

  // Check if a cURL exception occurred, and if so, notify things
  $curlException = $this
    ->isCurlException($request, $handle, $curl);

  // Always remove completed curl handles.  They can be added back again
  // via events if needed (e.g. ExponentialBackoffPlugin)
  $this
    ->removeHandle($request);
  if (!$curlException) {
    $request
      ->setState(RequestInterface::STATE_COMPLETE, array(
      'handle' => $handle,
    ));

    // Only remove the request if it wasn't resent as a result of the state change
    if ($request
      ->getState() != RequestInterface::STATE_TRANSFER) {
      $this
        ->remove($request);
    }
  }
  else {

    // Set the state of the request to an error
    $request
      ->setState(RequestInterface::STATE_ERROR);

    // Notify things that listen to the request of the failure
    $request
      ->dispatch('request.exception', array(
      'request' => $this,
      'exception' => $curlException,
    ));

    // Allow things to ignore the error if possible
    $state = $request
      ->getState();
    if ($state != RequestInterface::STATE_TRANSFER) {
      $this
        ->remove($request);
    }

    // The error was not handled, so fail
    if ($state == RequestInterface::STATE_ERROR) {

      /** @var $curlException \Exception */
      throw $curlException;
    }
  }
}