You are here

private static function CurlFactory::createRejection in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php \GuzzleHttp\Handler\CurlFactory::createRejection()
2 calls to CurlFactory::createRejection()
CurlFactory::finishError in vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
CurlFactory::retryFailedRewind in vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
This function ensures that a response was set on a transaction. If one was not set, then the request is retried if possible. This error typically means you are sending a payload, curl encountered a "Connection died, retrying a fresh connect"…

File

vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php, line 153

Class

CurlFactory
Creates curl resources from a request

Namespace

GuzzleHttp\Handler

Code

private static function createRejection(EasyHandle $easy, array $ctx) {
  static $connectionErrors = [
    CURLE_OPERATION_TIMEOUTED => true,
    CURLE_COULDNT_RESOLVE_HOST => true,
    CURLE_COULDNT_CONNECT => true,
    CURLE_SSL_CONNECT_ERROR => true,
    CURLE_GOT_NOTHING => true,
  ];

  // If an exception was encountered during the onHeaders event, then
  // return a rejected promise that wraps that exception.
  if ($easy->onHeadersException) {
    return new RejectedPromise(new RequestException('An error was encountered during the on_headers event', $easy->request, $easy->response, $easy->onHeadersException, $ctx));
  }
  $message = sprintf('cURL error %s: %s (%s)', $ctx['errno'], $ctx['error'], 'see http://curl.haxx.se/libcurl/c/libcurl-errors.html');

  // Create a connection exception if it was a specific error code.
  $error = isset($connectionErrors[$easy->errno]) ? new ConnectException($message, $easy->request, null, $ctx) : new RequestException($message, $easy->request, $easy->response, null, $ctx);
  return new RejectedPromise($error);
}