You are here

private function Mailchimp::getDefaultHttpClient in Mailchimp 8

Instantiates a default HTTP client based on the local environment.

Parameters

array $http_options: HTTP client options.

Return value

MailchimpHttpClientInterface The HTTP client.

1 call to Mailchimp::getDefaultHttpClient()
Mailchimp::__construct in lib/mailchimp-api-php/src/Mailchimp.php
Mailchimp constructor.

File

lib/mailchimp-api-php/src/Mailchimp.php, line 316

Class

Mailchimp
Mailchimp library.

Namespace

Mailchimp

Code

private function getDefaultHttpClient($http_options) {

  // Process HTTP options.
  // Handle deprecated 'timeout' argument.
  if (is_int($http_options)) {
    $http_options = [
      'timeout' => $http_options,
    ];
  }

  // Default timeout is 10 seconds.
  $http_options += [
    'timeout' => 10,
  ];
  $client = NULL;

  // Use cURL HTTP client if PHP version is below 5.5.0.
  // Use Guzzle client otherwise.
  if (version_compare(phpversion(), '5.5.0', '<')) {
    $client = new MailchimpCurlHttpClient($http_options);
  }
  else {
    $client = new MailchimpGuzzleHttpClient($http_options);
  }
  return $client;
}