Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal.php \Drupal::httpClient()
  2. 9 core/lib/Drupal.php \Drupal::httpClient()

Returns the default http client.

Return value

\GuzzleHttp\Client A guzzle http client instance.

10 calls to Drupal::httpClient()
DrupalTest::testHttpClient in core/tests/Drupal/Tests/Core/DrupalTest.php
Tests the httpClient() method.
StatisticsAdminTest::setUp in core/modules/statistics/tests/src/Functional/StatisticsAdminTest.php
StatisticsReportsTest::testPopularContentBlock in core/modules/statistics/tests/src/Functional/StatisticsReportsTest.php
Tests the "popular content" block.
StatisticsTokenReplaceTest::testStatisticsTokenReplacement in core/modules/statistics/tests/src/Functional/StatisticsTokenReplaceTest.php
Creates a node, then tests the statistics tokens generated from it.
StyleSerializerTest::testRestViewsAuthentication in core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php
Checks that the auth options restricts access to a REST views display.

... See full list

File

core/lib/Drupal.php, line 490

Class

Drupal
Static Service Container wrapper.

Code

public static function httpClient() {
  return static::getContainer()
    ->get('http_client');
}