You are here

private function CurlFactory::getDefaultConf in Lockr 7.3

1 call to CurlFactory::getDefaultConf()
CurlFactory::create in vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
Creates a cURL handle resource.

File

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

Class

CurlFactory
Creates curl resources from a request

Namespace

GuzzleHttp\Handler

Code

private function getDefaultConf(EasyHandle $easy) {
  $conf = [
    '_headers' => $easy->request
      ->getHeaders(),
    CURLOPT_CUSTOMREQUEST => $easy->request
      ->getMethod(),
    CURLOPT_URL => (string) $easy->request
      ->getUri()
      ->withFragment(''),
    CURLOPT_RETURNTRANSFER => false,
    CURLOPT_HEADER => false,
    CURLOPT_CONNECTTIMEOUT => 150,
  ];
  if (defined('CURLOPT_PROTOCOLS')) {
    $conf[CURLOPT_PROTOCOLS] = CURLPROTO_HTTP | CURLPROTO_HTTPS;
  }
  $version = $easy->request
    ->getProtocolVersion();
  if ($version == 1.1) {
    $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
  }
  elseif ($version == 2.0) {
    $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
  }
  else {
    $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
  }
  return $conf;
}