You are here

private function CurlRequest::createCurl in Smart IP 7.2

Same name and namespace in other branches
  1. 6.2 includes/vendor/maxmind/web-service-common/src/WebService/Http/CurlRequest.php \MaxMind\WebService\Http\CurlRequest::createCurl()

Return value

resource

2 calls to CurlRequest::createCurl()
CurlRequest::get in includes/vendor/maxmind/web-service-common/src/WebService/Http/CurlRequest.php
CurlRequest::post in includes/vendor/maxmind/web-service-common/src/WebService/Http/CurlRequest.php

File

includes/vendor/maxmind/web-service-common/src/WebService/Http/CurlRequest.php, line 53

Class

CurlRequest
This class is for internal use only. Semantic versioning does not not apply. @package MaxMind\WebService\Http @internal

Namespace

MaxMind\WebService\Http

Code

private function createCurl() {
  $curl = curl_init($this->url);
  $opts[CURLOPT_CAINFO] = $this->options['caBundle'];
  $opts[CURLOPT_SSL_VERIFYHOST] = 2;
  $opts[CURLOPT_FOLLOWLOCATION] = false;
  $opts[CURLOPT_SSL_VERIFYPEER] = true;
  $opts[CURLOPT_RETURNTRANSFER] = true;
  $opts[CURLOPT_HTTPHEADER] = $this->options['headers'];
  $opts[CURLOPT_USERAGENT] = $this->options['userAgent'];
  $opts[CURLOPT_PROXY] = $this->options['proxy'];

  // The defined()s are here as the *_MS opts are not available on older
  // cURL versions
  $connectTimeout = $this->options['connectTimeout'];
  if (defined('CURLOPT_CONNECTTIMEOUT_MS')) {
    $opts[CURLOPT_CONNECTTIMEOUT_MS] = ceil($connectTimeout * 1000);
  }
  else {
    $opts[CURLOPT_CONNECTTIMEOUT] = ceil($connectTimeout);
  }
  $timeout = $this->options['timeout'];
  if (defined('CURLOPT_TIMEOUT_MS')) {
    $opts[CURLOPT_TIMEOUT_MS] = ceil($timeout * 1000);
  }
  else {
    $opts[CURLOPT_TIMEOUT] = ceil($timeout);
  }
  curl_setopt_array($curl, $opts);
  return $curl;
}