PendingRequest
class PendingRequest
Traits
Properties
| protected Authenticator|null | $authenticator | The authenticator used in requests. |
from AuthenticatesRequests |
| protected BodyRepository|null | $bodyRepository | The request body repository. |
from HasBody |
| protected list<array<string, mixed>> | $cookies | The request cookies and their attributes. |
from HasCookies |
| protected IntegerRepository|null | $delayRepository | The request delay. |
from HasDelay |
| protected ArrayRepository|null | $headerRepository | The request headers. |
from HasHeaders |
| protected MiddlewarePipeline|null | $middlewarePipeline | The request middleware pipeline. |
from HasMiddleware |
| protected ArrayRepository|null | $optionRepository | The request options. |
from HasOptions |
| protected ArrayRepository|null | $queryRepository | The request query parameters. |
from HasQuery |
| protected string|null | $queryString | The already-encoded query string override. |
from HasQuery |
| protected RetryPolicy|null | $retryPolicy | The request retry policy. |
from HasRetryPolicy |
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected UriInterface|null | $uri | The finalized request URI. |
|
| protected StreamInterface|null | $preparedBody | The prepared request body. |
|
| protected bool | $bodyPrepared | Whether the operation body has been prepared. |
|
| protected int|null | $attemptBodyOffset | The body offset at the start of the transport attempt. |
|
| protected RequestInterface|null | $psrRequest | The final application-owned PSR request. |
|
| protected PendingRequest): void> | $psrRequestObservers | The final PSR request observers. |
|
| protected null|array{0: string, 1: string, 2?: string} | $transportAuthentication | The dedicated transport authentication option. |
|
| protected null|array{0: string, 1: string}|string | $certificate | The dedicated client certificate option. |
|
| protected FakeResponse|null | $fakeResponse | The response supplied by request middleware or a mock client. |
Methods
Authenticate the request with a token.
Authenticate the request with basic authentication.
Authenticate the request with digest authentication.
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Set the raw request body.
Attach a multipart value to the request.
Copy the body repository for a pending request.
Debug the final application-owned request.
Debug the response before ordinary response middleware.
Specify a cookie and its attributes for the request.
Specify cookies that should be included with the request.
Indicate the type of content that should be returned by the server.
Indicate that TLS certificates should not be verified.
Specify where the response body should be stored.
Specify the connection timeout in seconds.
Get the raw query string override, without a leading question mark.
Replace the raw query string and invalidate the finalized URI.
Add query parameters to the request.
Specify the number of times the request should be attempted.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a side-effect-free pending request.
Get the HTTP method.
Get the final request URI.
Finalize the request URI after ordinary request middleware.
Apply the configured authenticator.
Boot the connector and request plugins.
Execute the request middleware pipeline.
Execute the fatal exception middleware pipeline.
Prepare the request body after ordinary request middleware.
Get the prepared request body.
Set the dedicated transport authentication option.
Get the dedicated transport authentication option.
Set the client certificate option.
Get the client certificate option.
Observe the final application-owned PSR request.
Apply the connector and request PSR hooks.
Notify the final PSR request observers.
Create the logical PSR request for a short-circuit response.
Set the final application-owned PSR request.
Get the captured PSR request or create a logical snapshot.
Restore the attempt body before another attempt.
Get the fake response.
Validate the request's caching configuration.
Determine if this operation is cacheable.
Determine if the matching cache entry should be invalidated.
Get the cache duration.
Get the selected cache store.
Resolve the custom cache key.
Get the rate limiter manager.
Resolve the request or connector that owns cache duration and storage.
Create the response selected by this operation.
Get the current offset of a seekable stream.
Resolve the multipart content type when the caller did not provide one.
Flush all static state.
Details
in
AuthenticatesRequests at line 23
protected Authenticator|null
defaultAuth()
Resolve the default authenticator.
in
AuthenticatesRequests at line 31
Authenticator|null
authenticator()
Get the authenticator.
at line 242
PendingRequest
authenticate(Authenticator $authenticator)
Authenticate the pending request immediately.
in
AuthenticatesRequests at line 53
AuthenticatesRequests
withToken(string $token, string $type = 'Bearer')
Authenticate the request with a token.
in
AuthenticatesRequests at line 63
AuthenticatesRequests
withBasicAuth(string $username, string $password)
Authenticate the request with basic authentication.
in
AuthenticatesRequests at line 73
AuthenticatesRequests
withDigestAuth(string $username, string $password)
Authenticate the request with digest authentication.
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.
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.
in
HasBody at line 31
HasBody
withBody(mixed $content, string|null $contentType = 'application/json')
Set the raw request body.
in
HasBody at line 89
HasBody
attach(string $name, mixed $contents = '', string|null $filename = null, array $headers = [])
Attach a multipart value to the request.
in
HasBody at line 129
mixed
body()
Get the resolved request body value.
in
HasBody at line 137
bool
hasBody()
Determine if the request has a body repository.
in
HasBody at line 147
final BodyRepository|null
copyBodyRepository()
| internal |
Copy the body repository for a pending request.
in
HasBody at line 157
protected BodyRepository|null
defaultBodyRepository()
Resolve the default body repository.
in
HasBody at line 165
protected BodyRepository|null
bodyRepository()
Get the request body repository.
in
HasDebugging at line 22
HasDebugging
debugRequest(callable|null $onRequest = null, bool $die = false)
Debug the final application-owned request.
in
HasDebugging at line 50
HasDebugging
debugResponse(callable|null $onResponse = null, bool $die = false)
Debug the response before ordinary response middleware.
in
HasDebugging at line 81
HasDebugging
debug(bool $die = false)
Debug both the request and response.
Raw debugging output may contain credentials or other sensitive values.
in
HasCookies at line 25
HasCookies
withCookie(SetCookie $cookie)
Specify a cookie and its attributes for the request.
in
HasCookies at line 46
HasCookies
withCookies(array $cookies, string $domain)
Specify cookies that should be included with the request.
in
HasCookies at line 60
array
cookies()
Get the request cookies and their attributes.
in
HasDelay at line 22
HasDelay
delay(int $milliseconds)
Delay the request by the given milliseconds.
in
HasDelay at line 36
int|null
delayMilliseconds()
Get the request delay in milliseconds.
in
HasDelay at line 44
protected int|null
defaultDelay()
Resolve the default request delay.
in
HasDelay at line 52
protected IntegerRepository
delayRepository()
Get the request delay repository.
in
HasHeaders at line 21
array
headers()
Get the request headers.
in
HasHeaders at line 29
bool
hasHeader(string $name)
Determine if the request contains the given header.
in
HasHeaders at line 46
HasHeaders
withHeaders(array $headers)
Add headers to the request.
in
HasHeaders at line 58
HasHeaders
withHeader(string $name, mixed $value)
Add a header to the request.
in
HasHeaders at line 69
HasHeaders
replaceHeaders(array $headers)
Replace matching headers on the request.
in
HasHeaders at line 97
HasHeaders
contentType(string $contentType)
Specify the request content type.
in
HasHeaders at line 107
HasHeaders
acceptJson()
Indicate that JSON should be returned by the server.
in
HasHeaders at line 117
HasHeaders
accept(string $contentType)
Indicate the type of content that should be returned by the server.
in
HasHeaders at line 127
HasHeaders
withUserAgent(bool|string $userAgent)
Specify the request user agent.
in
HasHeaders at line 137
protected array
defaultHeaders()
Resolve the default request headers.
in
HasHeaders at line 145
protected ArrayRepository
headerRepository()
Get the request header repository.
in
HasMiddleware at line 19
MiddlewarePipeline
middleware()
Get the request middleware pipeline.
in
HasOptions at line 23
array
options()
Get the request options.
in
HasOptions at line 34
HasOptions
withOptions(array $options)
Add options to the request.
in
HasOptions at line 46
HasOptions
maxRedirects(int $max)
Specify the maximum number of redirects to allow.
in
HasOptions at line 64
HasOptions
withoutRedirecting()
Indicate that redirects should not be followed.
in
HasOptions at line 74
HasOptions
withoutVerifying()
Indicate that TLS certificates should not be verified.
in
HasOptions at line 85
HasOptions
sink(resource|StreamInterface|string $to)
Specify where the response body should be stored.
in
HasOptions at line 95
HasOptions
timeout(float|int $seconds)
Specify the request timeout in seconds.
in
HasOptions at line 105
HasOptions
connectTimeout(float|int $seconds)
Specify the connection timeout in seconds.
in
HasOptions at line 116
HasOptions
withTelescopeTags(array $tags)
Add Telescope tags to the request.
in
HasOptions at line 126
HasOptions
withoutTelescope()
Disable Telescope recording for the request.
in
HasOptions at line 136
protected array
defaultOptions()
Resolve the default request options.
in
HasOptions at line 144
protected ArrayRepository
optionRepository()
Get the request option repository.
in
HasQuery at line 24
string|null
queryString()
Get the raw query string override, without a leading question mark.
at line 230
PendingRequest
withQueryString(string $query)
Replace the raw query string and invalidate the finalized URI.
in
HasQuery at line 44
array
queryParameters()
Get the request query parameters.
at line 219
PendingRequest
withQueryParameters(array $parameters)
Add query parameters to the request.
in
HasQuery at line 67
protected array
defaultQuery()
Resolve the default request query parameters.
in
HasQuery at line 75
protected string|null
defaultQueryString()
Resolve the default raw query string override.
in
HasQuery at line 83
protected ArrayRepository
queryRepository()
Get the request query repository.
in
HasRetryPolicy at line 23
HasRetryPolicy
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.
in
HasRetryPolicy at line 37
RetryPolicy
retryPolicy()
Get the request retry policy.
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.
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.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
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.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 110
__construct(Connector $connector, Request $request, Factory $cache, RateLimiter $rateLimiter)
Create a side-effect-free pending request.
at line 155
Connector
connector()
Get the connector.
at line 165
Request
request()
Get the request.
at line 173
Method
method()
Get the HTTP method.
at line 181
UriInterface
uri()
Get the final request URI.
at line 206
PendingRequest
finalizeUri()
Finalize the request URI after ordinary request middleware.
at line 253
PendingRequest
applyAuthentication()
Apply the configured authenticator.
at line 263
PendingRequest
bootPlugins()
Boot the connector and request plugins.
at line 273
PendingRequest
mergeMiddleware(MiddlewarePipeline $middleware)
Merge worker-global middleware into this operation.
at line 283
PendingRequest
executeRequestPipeline()
Execute the request middleware pipeline.
at line 293
Response
executeResponsePipeline(Response $response)
Execute the response middleware pipeline.
at line 301
void
executeFatalPipeline(FatalRequestException $exception)
Execute the fatal exception middleware pipeline.
at line 309
PendingRequest
prepareBody()
Prepare the request body after ordinary request middleware.
at line 329
StreamInterface|null
preparedBody()
Get the prepared request body.
at line 340
PendingRequest
setTransportAuthentication(array $authentication)
Set the dedicated transport authentication option.
at line 352
array|null
transportAuthentication()
Get the dedicated transport authentication option.
at line 362
PendingRequest
setCertificate(string $path, string|null $password = null)
Set the client certificate option.
at line 374
array|string|null
certificate()
Get the client certificate option.
at line 385
PendingRequest
observePsrRequest(callable $observer)
Observe the final application-owned PSR request.
at line 395
RequestInterface
handlePsrRequest(RequestInterface $request)
Apply the connector and request PSR hooks.
at line 405
void
notifyPsrRequestObservers(RequestInterface $request)
Notify the final PSR request observers.
at line 417
RequestInterface
createPsrRequest()
| internal |
Create the logical PSR request for a short-circuit response.
at line 443
PendingRequest
setPsrRequest(RequestInterface $request)
Set the final application-owned PSR request.
at line 458
RequestInterface
toPsrRequest()
Get the captured PSR request or create a logical snapshot.
Before authoritative capture, the snapshot does not run PSR hooks or observers. It materializes the body from its repository instead of reusing a prepared stream, though caller-owned streams may be shared.
at line 482
bool
restoreAttemptBody()
Restore the attempt body before another attempt.
at line 504
PendingRequest
setFakeResponse(FakeResponse|null $fakeResponse)
Set the fake response.
at line 514
FakeResponse|null
fakeResponse()
Get the fake response.
at line 522
PendingRequest
validateCachingConfiguration()
Validate the request's caching configuration.
at line 537
bool
isCacheable()
Determine if this operation is cacheable.
at line 550
bool
shouldInvalidateCache()
Determine if the matching cache entry should be invalidated.
at line 558
DateInterval|DateTimeInterface|int
cacheFor()
Get the cache duration.
at line 567
UnitEnum|string|null
cacheStore()
Get the selected cache store.
at line 581
string|null
resolveCacheKey()
Resolve the custom cache key.
at line 590
Factory
cache()
Get the cache factory.
at line 598
RateLimiter
rateLimiter()
Get the rate limiter manager.
at line 606
protected Cacheable|null
cacheableResource()
Resolve the request or connector that owns cache duration and storage.
at line 620
Response
createResponse(Response $response, RequestInterface $request)
Create the response selected by this operation.
at line 635
string|null
resolveResponseClass(Response $response)
Resolve the custom response class.
at line 650
protected int|null
streamOffset(StreamInterface|null $stream)
Get the current offset of a seekable stream.
at line 658
protected string|null
multipartContentType()
Resolve the multipart content type when the caller did not provide one.
at line 670
static void
flushState()
Flush all static state.