class PendingRequest

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected ClientInterface|null $client

The Guzzle client instance.

protected callable $handler

The Guzzle HTTP handler.

protected string $baseUrl

The base URL for the request.

protected array $urlParameters

The parameters that can be substituted into the URL.

protected string $bodyFormat

The request body format.

protected null|resource|StreamInterface|string $pendingBody

The raw body for the request.

protected array $pendingFiles

The pending files for the request.

protected CookieJar $cookies

The request cookies.

protected TransferStats|null $transferStats

The transfer stats for the request.

protected array $options

The request options.

protected array $baseOptions

The factory-level options applied below connection and request options.

protected Closure|null $throwCallback

A callback to run when throwing if a server or client error occurs.

protected Closure|null $throwIfCallback

A callback to check if an exception should be thrown when a server or client error occurs.

protected array|int $tries

The number of times to try the request.

protected Closure|int $retryDelay

The number of milliseconds to wait between retries.

protected bool $retryThrow

Whether to throw an exception when all retries fail.

protected null|callable $retryWhenCallback

The callback that will determine if the request should be retried.

protected Collection $beforeSendingCallbacks

The callbacks that should execute before the request is sent.

protected Collection $afterResponseCallbacks

The callbacks that should execute after the response is built.

protected Collection|null $stubCallbacks

The stub callables that will handle requests.

protected bool $preventStrayRequests

Indicates that an exception should be thrown if any request is not faked.

protected array $allowedStrayRequestUrls

The URL patterns that are allowed as stray requests.

protected Collection $middleware

The middleware callables added by users that will handle requests.

protected bool $async

Whether the requests should be asynchronous.

protected array $attributes

The attributes to track with the request.

protected PromiseInterface|null $promise

The pending request promise.

protected Request|null $request

The sent request object, if a request has been made.

protected string|null $connection

The current connection name for the pending request.

protected array|null $connectionConfig

The current connection configuration for the pending request.

protected array $mergeableOptions

The Guzzle request options that are mergeable via array_merge_recursive.

protected false|int|null $truncateExceptionsAt

The length at which request exceptions will be truncated.

Methods

mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

__construct(Factory|null $factory = null, array $middleware = [], array $options = [])

Create a new HTTP Client instance.

baseUrl(string $url)

Set the base URL for the pending request.

withBody(mixed $content, string $contentType = 'application/json')

Attach a raw body to the request.

asJson()

Indicate the request contains JSON.

asForm()

Indicate the request contains form parameters.

attach(array|string $name, resource|string $contents = '', string|null $filename = null, array $headers = [])

Attach a file to the request.

asMultipart()

Indicate the request is a multi-part form request.

bodyFormat(string $format)

Specify the body format of the request.

withQueryParameters(array $parameters)

Set the given query parameters in the request URI.

contentType(string $contentType)

Specify the request's content type.

acceptJson()

Indicate that JSON should be returned by the server.

accept(string $contentType)

Indicate the type of content that should be returned by the server.

withHeaders(array $headers)

Add the given headers to the request.

withHeader(string $name, mixed $value)

Add the given header to the request.

replaceHeaders(array $headers)

Replace the given headers on the request.

withBasicAuth(string $username, string $password)

Specify the basic authentication username and password for the request.

withDigestAuth(string $username, string $password)

Specify the digest authentication username and password for the request.

withNtlmAuth(string $username, string $password)

Specify the NTLM authentication username and password for the request.

withToken(string $token, string $type = 'Bearer')

Specify an authorization token for the request.

withUserAgent(bool|string $userAgent)

Specify the user agent for the request.

withUrlParameters(array $parameters = [])

Specify the URL parameters that can be substituted into the request URL.

withCookies(array $cookies, string $domain)

Specify the cookies that should be included with the request.

maxRedirects(int $max)

Specify the maximum number of redirects to allow.

withoutRedirecting()

Indicate that redirects should not be followed.

withoutVerifying()

Indicate that TLS certificates should not be verified.

sink(resource|string $to)

Specify the path where the body of the response should be stored.

timeout(float|int $seconds)

Specify the timeout (in seconds) for the request.

connectTimeout(float|int $seconds)

Specify the connect timeout (in seconds) for the request.

retry(array|int $times, Closure|int $sleepMilliseconds = 0, callable|null $when = null, bool $throw = true)

Specify the number of times the request should be attempted.

withOptions(array $options)

Replace the specified options on the request.

withMiddleware(callable $middleware)

Add new middleware the client handler stack.

withRequestMiddleware(callable $middleware)

Add new request middleware the client handler stack.

withResponseMiddleware(callable $middleware)

Add new response middleware the client handler stack.

withAttributes(array $attributes)

Set arbitrary attributes to store with the request.

withoutTelescope()

Indicate that Telescope should not record this request.

withTelescopeTags(array $tags)

Set Telescope tags for this request.

beforeSending(callable $callback)

Add a new "before sending" callback to the request.

afterResponse(callable $callback)

Add a new callback to execute after the response is built.

throw(callable|null $callback = null)

Throw an exception if a server or client error occurs.

throwIf(bool|callable $condition)

Throw an exception if a server or client error occurred and the given condition evaluates to true.

throwUnless(bool|callable $condition)

Throw an exception if a server or client error occurred and the given condition evaluates to false.

dump()

Dump the request before sending.

dd()

Dump the request before sending and end the script.

PromiseInterface|Response
get(string $url, Arrayable|array|JsonSerializable|string|null $query = null)

Issue a GET request to the given URL.

PromiseInterface|Response
head(string $url, array|string|null $query = null)

Issue a HEAD request to the given URL.

PromiseInterface|Response
post(string $url, array|JsonSerializable $data = [])

Issue a POST request to the given URL.

PromiseInterface|Response
patch(string $url, array $data = [])

Issue a PATCH request to the given URL.

PromiseInterface|Response
put(string $url, array $data = [])

Issue a PUT request to the given URL.

PromiseInterface|Response
delete(string $url, array $data = [])

Issue a DELETE request to the given URL.

PromiseInterface|Response
send(string $method, string $url, array $options = [])

Send the request to the given URL.

string
expandUrlParameters(string $url)

Substitute the URL parameters in the given URL.

array
parseHttpOptions(array $options)

Parse the given HTTP options and set the appropriate additional options.

array
parseMultipartBodyFormat(array $data)

Parse multi-part form data.

PromiseInterface
makePromise(string $method, string $url, array $options = [], int $attempt = 1)

Send an asynchronous request to the given URL.

mixed
handlePromiseResponse(Response|Throwable $response, string $method, string $url, array $options, int $attempt)

Handle the response of an asynchronous request.

int
getMaximumAttempts()

Get the maximum number of attempts for the request.

int|float
retryDelayInMilliseconds(int $attempt, mixed $exception)

Get the delay in milliseconds before the next retry attempt.

PromiseInterface|ResponseInterface
sendRequest(string $method, string $url, array $options = [])

Send a request either synchronously or asynchronously.

array
parseRequestData(string $method, string $url, array $options)

Get the request data as an array so that we can attach it to the request for convenient assertions.

array
normalizeRequestOptions(array $options)

Normalize the given request options.

array
normalizeHeaderValues(array $headers)

Normalize the given header values.

string|array
normalizeHeaderValue(mixed $value)

Normalize the given header value.

array
normalizeNonFiniteFloatValues(array $values)

Normalize non-finite floats within a nested array.

array
normalizeMultipartOption(array $multipart)

Normalize the given multipart option.

array
normalizeMultipartHeaders(array $multipart)

Normalize the given multipart headers.

mixed
normalizeRequestOptionValue(mixed $value)

Normalize the given request option value.

string
normalizeScalarString(bool|float|int|string $value)

Normalize a scalar to a string without triggering PHP 8.5 non-finite float warnings.

void
ensureValidRequestBody(mixed $body)

Ensure the given request body can be passed to Guzzle.

populateResponse(Response $response)

Populate the given response with additional data.

ClientInterface
buildClient()

Build the Guzzle client.

bool
requestsReusableClient()

Determine if a reusable client is required.

ClientInterface
getReusableClient()

Retrieve a reusable Guzzle client.

HandlerStack
buildHandlerStack()

Build the Guzzle client handler stack.

HandlerStack
pushHandlers(HandlerStack $handlerStack)

Add the necessary handlers to the given handler stack.

buildBeforeSendingHandler()

Build the before sending handler.

buildRecorderHandler()

Build the recorder handler.

buildStubHandler()

Build the stub handler.

sinkStubHandler(resource|string $sink)

Get the sink stub handler callback.

RequestInterface
runBeforeSendingCallbacks(RequestInterface $request, array $options)

Execute the "before sending" callbacks.

array
mergeOptions(...$options)

Replace the given options with the current request options.

newResponse(PromiseInterface|ResponseInterface $response)

Create a new response instance using the given PSR response.

runAfterResponseCallbacks(Response $response)

Execute the "after response" callbacks.

stub(callable|Collection $callback)

Register a stub callable that will intercept requests and be able to return stub responses.

preventStrayRequests(bool $prevent = true)

Indicate that an exception should be thrown if any request is not faked.

allowStrayRequests(array $only)

Allow stray, unfaked requests for specific URL patterns.

bool
isAllowedRequestUrl(string $url)

Determine if the given URL is allowed as a stray request.

async(bool $async = true)

Toggle asynchronicity in requests.

PromiseInterface|null
getPromise()

Retrieve the pending request promise.

void
dispatchRequestSendingEvent()

Dispatch the RequestSending event if a dispatcher is available.

void
dispatchResponseReceivedEvent(Response $response)

Dispatch the ResponseReceived event if a dispatcher is available.

void
dispatchConnectionFailedEvent(Request $request, ConnectionException $exception)

Dispatch the ConnectionFailed event if a dispatcher is available.

truncateExceptionsAt(int $length)

Indicate that request exceptions should be truncated to the given length.

dontTruncateExceptions()

Indicate that request exceptions should not be truncated.

void
marshalConnectionException(ConnectException $e)

Handle the given connection exception.

void
marshalRequestExceptionWithoutResponse(RequestException $e)

Handle the given request exception with no response.

void
marshalRequestExceptionWithResponse(RequestException $e)

Handle the given request exception with a response.

setClient(ClientInterface $client)

Set the client instance.

setHandler(callable $handler)

Create a new client instance using the given handler.

array
getOptions()

Get the pending request options.

connection(string $connection, array|null $config = null)

Set the pending request connection.

string|null
getConnection()

Get the pending request connection.

array|null
getConnectionConfig()

No description

array
connectionOptions()

Get the effective request-option preset for the selected connection.

array
mergeOptionLayers(array ...$layers)

Merge HTTP option layers using the request-option merge rules.

void
validateRequestOptions(array $options, string $source)

Reject options whose ownership belongs to dedicated APIs.

static void
flushState()

Flush all static state.

Details

in Conditionable at line 23
mixed when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Conditionable at line 56
mixed unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Macroable at line 28
static void macro(string $name, callable|object $macro)

Register a custom macro.

Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 41
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 68
static void flushMacros()

Flush the existing macros.

Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 214
__construct(Factory|null $factory = null, array $middleware = [], array $options = [])

Create a new HTTP Client instance.

Parameters

Factory|null $factory
array $middleware
array $options

at line 247
PendingRequest baseUrl(string $url)

Set the base URL for the pending request.

Parameters

string $url

Return Value

PendingRequest

at line 261
PendingRequest withBody(mixed $content, string $contentType = 'application/json')

Attach a raw body to the request.

Parameters

mixed $content
string $contentType

Return Value

PendingRequest

Exceptions

InvalidArgumentException

at line 279
PendingRequest asJson()

Indicate the request contains JSON.

Return Value

PendingRequest

at line 287
PendingRequest asForm()

Indicate the request contains form parameters.

Return Value

PendingRequest

at line 297
PendingRequest attach(array|string $name, resource|string $contents = '', string|null $filename = null, array $headers = [])

Attach a file to the request.

Parameters

array|string $name
resource|string $contents
string|null $filename
array $headers

Return Value

PendingRequest

at line 326
PendingRequest asMultipart()

Indicate the request is a multi-part form request.

Return Value

PendingRequest

at line 334
PendingRequest bodyFormat(string $format)

Specify the body format of the request.

Parameters

string $format

Return Value

PendingRequest

at line 344
PendingRequest withQueryParameters(array $parameters)

Set the given query parameters in the request URI.

Parameters

array $parameters

Return Value

PendingRequest

at line 356
PendingRequest contentType(string $contentType)

Specify the request's content type.

Parameters

string $contentType

Return Value

PendingRequest

at line 366
PendingRequest acceptJson()

Indicate that JSON should be returned by the server.

Return Value

PendingRequest

at line 374
PendingRequest accept(string $contentType)

Indicate the type of content that should be returned by the server.

Parameters

string $contentType

Return Value

PendingRequest

at line 382
PendingRequest withHeaders(array $headers)

Add the given headers to the request.

Parameters

array $headers

Return Value

PendingRequest

at line 394
PendingRequest withHeader(string $name, mixed $value)

Add the given header to the request.

Parameters

string $name
mixed $value

Return Value

PendingRequest

at line 402
PendingRequest replaceHeaders(array $headers)

Replace the given headers on the request.

Parameters

array $headers

Return Value

PendingRequest

at line 412
PendingRequest withBasicAuth(string $username, string $password)

Specify the basic authentication username and password for the request.

Parameters

string $username
string $password

Return Value

PendingRequest

at line 422
PendingRequest withDigestAuth(string $username, string $password)

Specify the digest authentication username and password for the request.

Parameters

string $username
string $password

Return Value

PendingRequest

at line 432
PendingRequest withNtlmAuth(string $username, string $password)

Specify the NTLM authentication username and password for the request.

Parameters

string $username
string $password

Return Value

PendingRequest

at line 442
PendingRequest withToken(string $token, string $type = 'Bearer')

Specify an authorization token for the request.

Parameters

string $token
string $type

Return Value

PendingRequest

at line 452
PendingRequest withUserAgent(bool|string $userAgent)

Specify the user agent for the request.

Parameters

bool|string $userAgent

Return Value

PendingRequest

at line 462
PendingRequest withUrlParameters(array $parameters = [])

Specify the URL parameters that can be substituted into the request URL.

Parameters

array $parameters

Return Value

PendingRequest

at line 472
PendingRequest withCookies(array $cookies, string $domain)

Specify the cookies that should be included with the request.

Parameters

array $cookies
string $domain

Return Value

PendingRequest

at line 484
PendingRequest maxRedirects(int $max)

Specify the maximum number of redirects to allow.

Parameters

int $max

Return Value

PendingRequest

at line 494
PendingRequest withoutRedirecting()

Indicate that redirects should not be followed.

Return Value

PendingRequest

at line 504
PendingRequest withoutVerifying()

Indicate that TLS certificates should not be verified.

Return Value

PendingRequest

at line 516
PendingRequest sink(resource|string $to)

Specify the path where the body of the response should be stored.

Parameters

resource|string $to

Return Value

PendingRequest

at line 526
PendingRequest timeout(float|int $seconds)

Specify the timeout (in seconds) for the request.

Parameters

float|int $seconds

Return Value

PendingRequest

at line 536
PendingRequest connectTimeout(float|int $seconds)

Specify the connect timeout (in seconds) for the request.

Parameters

float|int $seconds

Return Value

PendingRequest

at line 546
PendingRequest retry(array|int $times, Closure|int $sleepMilliseconds = 0, callable|null $when = null, bool $throw = true)

Specify the number of times the request should be attempted.

Parameters

array|int $times
Closure|int $sleepMilliseconds
callable|null $when
bool $throw

Return Value

PendingRequest

at line 563
PendingRequest withOptions(array $options)

Replace the specified options on the request.

Parameters

array $options

Return Value

PendingRequest

at line 574
PendingRequest withMiddleware(callable $middleware)

Add new middleware the client handler stack.

Parameters

callable $middleware

Return Value

PendingRequest

at line 584
PendingRequest withRequestMiddleware(callable $middleware)

Add new request middleware the client handler stack.

Parameters

callable $middleware

Return Value

PendingRequest

at line 594
PendingRequest withResponseMiddleware(callable $middleware)

Add new response middleware the client handler stack.

Parameters

callable $middleware

Return Value

PendingRequest

at line 604
PendingRequest withAttributes(array $attributes)

Set arbitrary attributes to store with the request.

Parameters

array $attributes

Return Value

PendingRequest

at line 614
PendingRequest withoutTelescope()

Indicate that Telescope should not record this request.

Return Value

PendingRequest

at line 624
PendingRequest withTelescopeTags(array $tags)

Set Telescope tags for this request.

Parameters

array $tags

Return Value

PendingRequest

at line 632
PendingRequest beforeSending(callable $callback)

Add a new "before sending" callback to the request.

Parameters

callable $callback

Return Value

PendingRequest

at line 642
PendingRequest afterResponse(callable $callback)

Add a new callback to execute after the response is built.

Parameters

callable $callback

Return Value

PendingRequest

at line 652
PendingRequest throw(callable|null $callback = null)

Throw an exception if a server or client error occurs.

Parameters

callable|null $callback

Return Value

PendingRequest

at line 662
PendingRequest throwIf(bool|callable $condition)

Throw an exception if a server or client error occurred and the given condition evaluates to true.

Parameters

bool|callable $condition

Return Value

PendingRequest

at line 674
PendingRequest throwUnless(bool|callable $condition)

Throw an exception if a server or client error occurred and the given condition evaluates to false.

Parameters

bool|callable $condition

Return Value

PendingRequest

at line 682
PendingRequest dump()

Dump the request before sending.

Return Value

PendingRequest

at line 696
PendingRequest dd()

Dump the request before sending and end the script.

Return Value

PendingRequest

at line 714
PromiseInterface|Response get(string $url, Arrayable|array|JsonSerializable|string|null $query = null)

Issue a GET request to the given URL.

Parameters

string $url
Arrayable|array|JsonSerializable|string|null $query

Return Value

PromiseInterface|Response

Exceptions

ConnectionException

at line 730
PromiseInterface|Response head(string $url, array|string|null $query = null)

Issue a HEAD request to the given URL.

Parameters

string $url
array|string|null $query

Return Value

PromiseInterface|Response

Exceptions

ConnectionException

at line 746
PromiseInterface|Response post(string $url, array|JsonSerializable $data = [])

Issue a POST request to the given URL.

Parameters

string $url
array|JsonSerializable $data

Return Value

PromiseInterface|Response

Exceptions

ConnectionException

at line 758
PromiseInterface|Response patch(string $url, array $data = [])

Issue a PATCH request to the given URL.

Parameters

string $url
array $data

Return Value

PromiseInterface|Response

Exceptions

ConnectionException

at line 770
PromiseInterface|Response put(string $url, array $data = [])

Issue a PUT request to the given URL.

Parameters

string $url
array $data

Return Value

PromiseInterface|Response

Exceptions

ConnectionException

at line 782
PromiseInterface|Response delete(string $url, array $data = [])

Issue a DELETE request to the given URL.

Parameters

string $url
array $data

Return Value

PromiseInterface|Response

Exceptions

ConnectionException

at line 804
PromiseInterface|Response send(string $method, string $url, array $options = [])

Send the request to the given URL.

Parameters

string $method
string $url
array $options

Return Value

PromiseInterface|Response

Exceptions

Exception
Throwable

at line 897
protected string expandUrlParameters(string $url)

Substitute the URL parameters in the given URL.

Parameters

string $url

Return Value

string

at line 905
protected array parseHttpOptions(array $options)

Parse the given HTTP options and set the appropriate additional options.

Parameters

array $options

Return Value

array

at line 938
protected array parseMultipartBodyFormat(array $data)

Parse multi-part form data.

Parameters

array $data

Return Value

array

at line 958
protected PromiseInterface makePromise(string $method, string $url, array $options = [], int $attempt = 1)

Send an asynchronous request to the given URL.

Parameters

string $method
string $url
array $options
int $attempt

Return Value

PromiseInterface

Exceptions

Exception

at line 1006
protected mixed handlePromiseResponse(Response|Throwable $response, string $method, string $url, array $options, int $attempt)

Handle the response of an asynchronous request.

Parameters

Response|Throwable $response
string $method
string $url
array $options
int $attempt

Return Value

mixed

Exceptions

Exception

at line 1059
protected int getMaximumAttempts()

Get the maximum number of attempts for the request.

Return Value

int

at line 1069
protected int|float retryDelayInMilliseconds(int $attempt, mixed $exception)

Get the delay in milliseconds before the next retry attempt.

Parameters

int $attempt
mixed $exception

Return Value

int|float

at line 1081
protected PromiseInterface|ResponseInterface sendRequest(string $method, string $url, array $options = [])

Send a request either synchronously or asynchronously.

Parameters

string $method
string $url
array $options

Return Value

PromiseInterface|ResponseInterface

Exceptions

Exception

at line 1105
protected array parseRequestData(string $method, string $url, array $options)

Get the request data as an array so that we can attach it to the request for convenient assertions.

Parameters

string $method
string $url
array $options

Return Value

array

at line 1137
protected array normalizeRequestOptions(array $options)

Normalize the given request options.

Parameters

array $options

Return Value

array

at line 1177
protected array normalizeHeaderValues(array $headers)

Normalize the given header values.

Parameters

array $headers

Return Value

array

at line 1191
protected string|array normalizeHeaderValue(mixed $value)

Normalize the given header value.

Parameters

mixed $value

Return Value

string|array

Exceptions

InvalidArgumentException

at line 1221
protected array normalizeNonFiniteFloatValues(array $values)

Normalize non-finite floats within a nested array.

Parameters

array $values

Return Value

array

at line 1237
protected array normalizeMultipartOption(array $multipart)

Normalize the given multipart option.

Parameters

array $multipart

Return Value

array

at line 1273
protected array normalizeMultipartHeaders(array $multipart)

Normalize the given multipart headers.

Parameters

array $multipart

Return Value

array

Exceptions

InvalidArgumentException

at line 1295
protected mixed normalizeRequestOptionValue(mixed $value)

Normalize the given request option value.

Parameters

mixed $value

Return Value

mixed

at line 1309
protected string normalizeScalarString(bool|float|int|string $value)

Normalize a scalar to a string without triggering PHP 8.5 non-finite float warnings.

Parameters

bool|float|int|string $value

Return Value

string

at line 1327
protected void ensureValidRequestBody(mixed $body)

Ensure the given request body can be passed to Guzzle.

Parameters

mixed $body

Return Value

void

Exceptions

InvalidArgumentException

at line 1337
protected Response populateResponse(Response $response)

Populate the given response with additional data.

Parameters

Response $response

Return Value

Response

at line 1349
ClientInterface buildClient()

Build the Guzzle client.

Return Value

ClientInterface

at line 1366
protected bool requestsReusableClient()

Determine if a reusable client is required.

Return Value

bool

at line 1374
protected ClientInterface getReusableClient()

Retrieve a reusable Guzzle client.

Return Value

ClientInterface

at line 1382
HandlerStack buildHandlerStack()

Build the Guzzle client handler stack.

Return Value

HandlerStack

at line 1396
HandlerStack pushHandlers(HandlerStack $handlerStack)

Add the necessary handlers to the given handler stack.

Parameters

HandlerStack $handlerStack

Return Value

HandlerStack

at line 1412
Closure buildBeforeSendingHandler()

Build the before sending handler.

Return Value

Closure

at line 1424
Closure buildRecorderHandler()

Build the recorder handler.

Return Value

Closure

at line 1447
Closure buildStubHandler()

Build the stub handler.

Return Value

Closure

at line 1483
protected Closure sinkStubHandler(resource|string $sink)

Get the sink stub handler callback.

Parameters

resource|string $sink

Return Value

Closure

at line 1502
RequestInterface runBeforeSendingCallbacks(RequestInterface $request, array $options)

Execute the "before sending" callbacks.

Parameters

RequestInterface $request
array $options

Return Value

RequestInterface

at line 1527
array mergeOptions(...$options)

Replace the given options with the current request options.

Parameters

...$options

Return Value

array

at line 1548
protected Response newResponse(PromiseInterface|ResponseInterface $response)

Create a new response instance using the given PSR response.

Parameters

PromiseInterface|ResponseInterface $response

Return Value

Response

at line 1564
protected Response runAfterResponseCallbacks(Response $response)

Execute the "after response" callbacks.

Parameters

Response $response

Return Value

Response

at line 1580
PendingRequest stub(callable|Collection $callback)

Register a stub callable that will intercept requests and be able to return stub responses.

Parameters

callable|Collection $callback

Return Value

PendingRequest

at line 1592
PendingRequest preventStrayRequests(bool $prevent = true)

Indicate that an exception should be thrown if any request is not faked.

Parameters

bool $prevent

Return Value

PendingRequest

at line 1602
PendingRequest allowStrayRequests(array $only)

Allow stray, unfaked requests for specific URL patterns.

Parameters

array $only

Return Value

PendingRequest

at line 1612
bool isAllowedRequestUrl(string $url)

Determine if the given URL is allowed as a stray request.

Parameters

string $url

Return Value

bool

at line 1630
PendingRequest async(bool $async = true)

Toggle asynchronicity in requests.

Parameters

bool $async

Return Value

PendingRequest

at line 1640
PromiseInterface|null getPromise()

Retrieve the pending request promise.

Return Value

PromiseInterface|null

at line 1648
protected void dispatchRequestSendingEvent()

Dispatch the RequestSending event if a dispatcher is available.

Return Value

void

at line 1658
protected void dispatchResponseReceivedEvent(Response $response)

Dispatch the ResponseReceived event if a dispatcher is available.

Parameters

Response $response

Return Value

void

at line 1670
protected void dispatchConnectionFailedEvent(Request $request, ConnectionException $exception)

Dispatch the ConnectionFailed event if a dispatcher is available.

Parameters

Request $request
ConnectionException $exception

Return Value

void

at line 1680
PendingRequest truncateExceptionsAt(int $length)

Indicate that request exceptions should be truncated to the given length.

Parameters

int $length

Return Value

PendingRequest

at line 1690
PendingRequest dontTruncateExceptions()

Indicate that request exceptions should not be truncated.

Return Value

PendingRequest

at line 1702
protected void marshalConnectionException(ConnectException $e)

Handle the given connection exception.

Parameters

ConnectException $e

Return Value

void

Exceptions

ConnectionException

at line 1720
protected void marshalRequestExceptionWithoutResponse(RequestException $e)

Handle the given request exception with no response.

Parameters

RequestException $e

Return Value

void

Exceptions

ConnectionException

at line 1739
protected void marshalRequestExceptionWithResponse(RequestException $e)

Handle the given request exception with a response.

Parameters

RequestException $e

Return Value

void

Exceptions

ConnectionException
RequestException

at line 1754
PendingRequest setClient(ClientInterface $client)

Set the client instance.

Parameters

ClientInterface $client

Return Value

PendingRequest

at line 1764
PendingRequest setHandler(callable $handler)

Create a new client instance using the given handler.

Parameters

callable $handler

Return Value

PendingRequest

at line 1774
array getOptions()

Get the pending request options.

Return Value

array

at line 1786
PendingRequest connection(string $connection, array|null $config = null)

Set the pending request connection.

Parameters

string $connection
array|null $config

Return Value

PendingRequest

at line 1805
string|null getConnection()

Get the pending request connection.

Return Value

string|null

at line 1810
array|null getConnectionConfig()

No description

Return Value

array|null

at line 1818
protected array connectionOptions()

Get the effective request-option preset for the selected connection.

Return Value

array

at line 1834
protected array mergeOptionLayers(array ...$layers)

Merge HTTP option layers using the request-option merge rules.

Parameters

array ...$layers

Return Value

array

at line 1853
protected void validateRequestOptions(array $options, string $source)

Reject options whose ownership belongs to dedicated APIs.

Parameters

array $options
string $source

Return Value

void

at line 1861
static void flushState()

Flush all static state.

Return Value

void