\Drupal\strata\Storage HttpTransport

Carries one provider request to an endpoint over the HTTP client Drupal already ships.

Every remote provider takes its transport as a callable, so the whole provider is exercised against canned responses with no network and no credentials. This is the one that talks to a real endpoint.

A 4xx or 5xx is a normal answer here, not an exception: the provider reads the status itself and decides what it means, since a 404 from a head is absence while a 404 from a get is an error. The client's own exceptions are therefore unwrapped back into a status where they carry a response, and only a genuine transport failure - a refused connection, a timeout, a DNS failure - surfaces as a status of 0 with the reason in the body.

Summary

Methods
Properties
Constants
__construct
__invoke
No public properties found
DEFAULT_TIMEOUT
DEFAULT_CONNECT_TIMEOUT
No protected methods found
No protected properties found
No protected constants found
No private methods found
client
timeout
connectTimeout
No private constants found

Constant

DEFAULT_TIMEOUT

DEFAULT_TIMEOUT = 120

Seconds a single request may take before it is abandoned.

DEFAULT_CONNECT_TIMEOUT

DEFAULT_CONNECT_TIMEOUT = 10

Seconds to wait for a connection.

Properties

$client

$client : \GuzzleHttp\ClientInterface

Type

ClientInterface

$timeout

$timeout : int

Type

int

$connectTimeout

$connectTimeout : int

Type

int

Methods

__construct()

__construct(\GuzzleHttp\ClientInterface  $client, int  $timeout = \self::DEFAULT_TIMEOUT, int  $connectTimeout = \self::DEFAULT_CONNECT_TIMEOUT) : mixed

Constructs a transport.

Parameters

\GuzzleHttp\ClientInterface $client

The HTTP client.

int $timeout

Seconds a request may take.

int $connectTimeout

Seconds to wait for a connection.

Returns

mixed —

__invoke()

__invoke(string  $method, string  $url, array  $headers = [], string|null  $body = null) : array{status: int, body: string, headers: array<string,string>}

Sends one request.

Parameters

string $method

HTTP method.

string $url

Absolute URL.

array $headers

Headers, including whatever authorization the caller produced.

string|null $body

Request body, or NULL.

Returns

array{status: int, body: string, headers: array} —

The response. A status of 0 means the request never reached the endpoint.