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

1.72.2 (latest) 1.72.1 1.71.2 1.70.0 1.69.0 1.68.2 1.67.0 1.66.0 1.65.0 1.64.3 1.63.0 1.62.3 1.61.0 1.60.1 1.59.1 1.58.2 1.53.0 1.52.11 1.51.2 1.50.0 1.49.3 1.48.1 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** ||
|---|---|
| **Name** | **Description** |
| `config` | `array` Configuration options. Please see 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`. |
| `↳ universeDomain` | `string` The expected universe of the credentials. Defaults to "googleapis.com". |
| `↳ restRetryListener` | `callable` A function to run custom logic between retries. This function can modify the next server call arguments for the next retry. |

### send

Deliver the request.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `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** ||
|---|---|
| **Type** | **Description** |
| `Psr\Http\Message\ResponseInterface` |   |

### sendAsync

Deliver the request asynchronously.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `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** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<Psr\Http\Message\ResponseInterface>` |   |