You are here

protected function ThunderAwsTestFixtureTrait::getHttpClient in Thunder 6.2.x

Same name and namespace in other branches
  1. 8.5 tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getHttpClient()
  2. 8.2 tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getHttpClient()
  3. 8.3 tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getHttpClient()
  4. 8.4 tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getHttpClient()
  5. 6.0.x tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getHttpClient()
  6. 6.1.x tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getHttpClient()

Creates a HTTP client.

Does not use the container because it is not always available in testing.

Return value

\GuzzleHttp\Client The HTTP client.

1 call to ThunderAwsTestFixtureTrait::getHttpClient()
ThunderAwsTestFixtureTrait::getTestFixture in tests/src/Traits/ThunderAwsTestFixtureTrait.php
Gets a test fixture from AWS.

File

tests/src/Traits/ThunderAwsTestFixtureTrait.php, line 54

Class

ThunderAwsTestFixtureTrait
Trait to download test fixtures from AWS.

Namespace

Drupal\Tests\thunder\Traits

Code

protected function getHttpClient() {
  $default_config = [
    // Security consideration: we must not use the certificate authority
    // file shipped with Guzzle because it can easily get outdated if a
    // certificate authority is hacked. Instead, we rely on the certificate
    // authority file provided by the operating system which is more likely
    // going to be updated in a timely fashion. This overrides the default
    // path to the pem file bundled with Guzzle.
    'verify' => TRUE,
    'timeout' => 30,
    'headers' => [
      'User-Agent' => 'Drupal/' . \Drupal::VERSION . ' (+https://www.drupal.org/) ' . \GuzzleHttp\default_user_agent(),
    ],
    // Security consideration: prevent Guzzle from using environment variables
    // to configure the outbound proxy.
    'proxy' => [
      'http' => NULL,
      'https' => NULL,
      'no' => [],
    ],
  ];
  $config = NestedArray::mergeDeep($default_config, Settings::get('http_client_config', []));
  return new Client($config);
}