Google Cloud PHP shared dependency, providing functionality useful to all components. Client - Class RequestWrapper (1.52.11)

Reference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class RequestWrapper.

The RequestWrapper is responsible for delivering and signing requests.

Namespace

Google \ Cloud \ Core

Methods

__construct

Parameters
NameDescription
config array

Configuration options. Please see Google\Cloud\Core\RequestWrapperTrait::setCommonDefaults() for the other available options.

↳ componentVersion string

The current version of the component from which the request originated.

↳ accessToken string

Access token used to sign requests. Deprecated: This option is no longer supported. Use the $credentialsFetcher option instead.

↳ asyncHttpHandler callable

Experimental A handler used to deliver PSR-7 requests asynchronously. Function signature should match: function (RequestInterface $request, array $options = []) : PromiseInterface<ResponseInterface>.

↳ authHttpHandler callable

A handler used to deliver PSR-7 requests specifically for authentication. Function signature should match: function (RequestInterface $request, array $options = []) : ResponseInterface.

↳ httpHandler callable

A handler used to deliver PSR-7 requests. Function signature should match: function (RequestInterface $request, array $options = []) : ResponseInterface.

↳ restOptions array

HTTP client specific configuration options.

↳ shouldSignRequest bool

Whether to enable request signing.

↳ restRetryFunction callable

Sets the conditions for whether or not a request should attempt to retry. Function signature should match: function (\Exception $ex) : bool.

↳ restDelayFunction callable

Executes a delay, defaults to utilizing usleep. Function signature should match: function (int $delay) : void.

↳ restCalcDelayFunction callable

Sets the conditions for determining how long to wait between attempts to retry. Function signature should match: function (int $attempt) : int.

send

Deliver the request.

Parameters
NameDescription
request Psr\Http\Message\RequestInterface

A PSR-7 request.

options array

Request options.

↳ requestTimeout float

Seconds to wait before timing out the request. Defaults to 0.

↳ retries int

Number of retries for a failed request. Defaults to 3.

↳ restRetryFunction callable

Sets the conditions for whether or not a request should attempt to retry. Function signature should match: function (\Exception $ex) : bool.

↳ restRetryListener callable

Runs after the restRetryFunction. This might be used to simply consume the exception and $arguments b/w retries. This returns the new $arguments thus allowing modification on demand for $arguments. For ex: changing the headers in b/w retries.

↳ restDelayFunction callable

Executes a delay, defaults to utilizing usleep. Function signature should match: function (int $delay) : void.

↳ restCalcDelayFunction callable

Sets the conditions for determining how long to wait between attempts to retry. Function signature should match: function (int $attempt) : int.

↳ restOptions array

HTTP client specific configuration options.

Returns
TypeDescription
Psr\Http\Message\ResponseInterface

sendAsync

Deliver the request asynchronously.

Parameters
NameDescription
request Psr\Http\Message\RequestInterface

A PSR-7 request.

options array

Request options.

↳ requestTimeout float

Seconds to wait before timing out the request. Defaults to 0.

↳ retries int

Number of retries for a failed request. Defaults to 3.

↳ restRetryFunction callable

Sets the conditions for whether or not a request should attempt to retry. Function signature should match: function (\Exception $ex, int $retryAttempt) : bool.

↳ restDelayFunction callable

Executes a delay, defaults to utilizing usleep. Function signature should match: function (int $delay) : void.

↳ restCalcDelayFunction callable

Sets the conditions for determining how long to wait between attempts to retry. Function signature should match: function (int $attempt) : int.

↳ restOptions array

HTTP client specific configuration options.

Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface<\psr\http\message\responseinterface>