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

Breadcrumb

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

function CurlFactory::create

Overrides CurlFactoryInterface::create

File

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

Class

CurlFactory
Creates curl resources from a request

Namespace

GuzzleHttp\Handler

Code

public function create(RequestInterface $request, array $options) : EasyHandle {
    $protocolVersion = $request->getProtocolVersion();
    if ('2' === $protocolVersion || '2.0' === $protocolVersion) {
        if (!self::supportsHttp2()) {
            throw new ConnectException('HTTP/2 is supported by the cURL handler, however libcurl is built without HTTP/2 support.', $request);
        }
    }
    elseif ('1.0' !== $protocolVersion && '1.1' !== $protocolVersion) {
        throw new ConnectException(sprintf('HTTP/%s is not supported by the cURL handler.', $protocolVersion), $request);
    }
    if (isset($options['curl']['body_as_string'])) {
        $options['_body_as_string'] = $options['curl']['body_as_string'];
        unset($options['curl']['body_as_string']);
    }
    $easy = new EasyHandle();
    $easy->request = $request;
    $easy->options = $options;
    $conf = $this->getDefaultConf($easy);
    $this->applyMethod($easy, $conf);
    $this->applyHandlerOptions($easy, $conf);
    $this->applyHeaders($easy, $conf);
    unset($conf['_headers']);
    // Add handler options from the request configuration options
    if (isset($options['curl'])) {
        $conf = \array_replace($conf, $options['curl']);
    }
    $conf[\CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
    $easy->handle = $this->handles ? \array_pop($this->handles) : \curl_init();
    curl_setopt_array($easy->handle, $conf);
    return $easy;
}

API Navigation

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