Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CurlFactory.php

function 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 219

Class

CurlFactory
Creates curl resources from a request

Namespace

GuzzleHttp\Handler

Code

private static function createRejection(EasyHandle $easy, array $ctx) : PromiseInterface {
    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 ($easy->createResponseException) {
        return P\Create::rejectionFor(new RequestException('An error was encountered while creating the response', $easy->request, $easy->response, $easy->createResponseException, $ctx));
    }
    // If an exception was encountered during the onHeaders event, then
    // return a rejected promise that wraps that exception.
    if ($easy->onHeadersException) {
        return P\Create::rejectionFor(new RequestException('An error was encountered during the on_headers event', $easy->request, $easy->response, $easy->onHeadersException, $ctx));
    }
    $uri = $easy->request
        ->getUri();
    $sanitizedError = self::sanitizeCurlError($ctx['error'] ?? '', $uri);
    $message = \sprintf('cURL error %s: %s (%s)', $ctx['errno'], $sanitizedError, 'see https://curl.haxx.se/libcurl/c/libcurl-errors.html');
    if ('' !== $sanitizedError) {
        $redactedUriString = \GuzzleHttp\Psr7\Utils::redactUserInfo($uri)->__toString();
        if ($redactedUriString !== '' && false === \strpos($sanitizedError, $redactedUriString)) {
            $message .= \sprintf(' for %s', $redactedUriString);
        }
    }
    // 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 P\Create::rejectionFor($error);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal