You are here

public function CurlFactory::create in Auth0 Single Sign On 8.2

Creates a cURL handle resource.

Parameters

RequestInterface $request Request:

array $options Transfer options:

Return value

EasyHandle

Throws

\RuntimeException when an option cannot be applied

Overrides CurlFactoryInterface::create

File

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

Class

CurlFactory
Creates curl resources from a request

Namespace

GuzzleHttp\Handler

Code

public function create(RequestInterface $request, array $options) {
  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;
}