public function Client::__construct

Same name in this branch

Client constructor

Parameters

string $baseUrl Base URL of the web service:

array|Collection $config Configuration settings:

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Client.php, line 72

Class

Client
HTTP client

Namespace

Guzzle\Http

Code

public function __construct($baseUrl = '', $config = null) {
  $this
    ->setConfig($config ?: new Collection());

  // Allow ssl.certificate_authority config setting to control the certificate authority used by curl
  $authority = $this->config
    ->get(self::SSL_CERT_AUTHORITY);

  // Use the system's cacert if in a phar (curl can't read from a phar stream wrapper)
  if (strpos(__FILE__, 'phar://') === false && $authority === true) {
    $authority = 'system';
  }

  // Set the config setting to system to use the certificate authority bundle on your system
  if ($authority !== 'system') {
    $this
      ->setSslVerification($authority !== null ? $authority : true);
  }
  $this
    ->setBaseUrl($baseUrl);
  $this->defaultHeaders = new Collection();
  $this
    ->setRequestFactory(RequestFactory::getInstance());

  // Redirect by default, but allow for redirects to be globally disabled on a client
  if (!$this->config
    ->get(self::DISABLE_REDIRECTS)) {
    $this
      ->addSubscriber(new RedirectPlugin());
  }
}