PendingRequest
Uses
Properties
$client GuzzleHttp\Client
The Guzzle client instance.
$handler callable
The Guzzle HTTP handler.
$baseUrl string
The base URL for the request.
$urlParameters array
The parameters that can be substituted into the URL.
$bodyFormat string
The request body format.
$pendingBody string
The raw body for the request.
$pendingFiles array
The pending files for the request.
$cookies array
The request cookies.
$transferStats GuzzleHttp\TransferStats
The transfer stats for the request.
$options array
The request options.
$throwCallback Closure
A callback to run when throwing if a server or client error occurs.
$throwIfCallback Closure
A callback to check if an exception should be thrown when a server or client error occurs.
$tries int
The number of times to try the request.
$retryThrow bool
Whether to throw an exception when all retries fail.
$retryWhenCallback callable|null
The callback that will determine if the request should be retried.
$beforeSendingCallbacks Illuminate\...\Collection
The callbacks that should execute before the request is sent.
$stubCallbacks Illuminate\...\Collection|null
The stub callables that will handle requests.
$preventStrayRequests bool
Indicates that an exception should be thrown if any request is not faked.
$middleware Illuminate\...\Collection
The middleware callables added by users that will handle requests.
$async bool
Whether the requests should be asynchronous.
$promise GuzzleHttp\...\PromiseInterface
The pending request promise.
$mergableOptions array
The Guzzle request options that are mergable via array_merge_recursive.
Methods
__construct ( Factory $factory , $middleware ) : void
Create a new HTTP Client instance.
Parameters
- $factory Factory |null
- $middleware array
baseUrl ( string $url ) : $this
Set the base URL for the pending request.
Parameters
- $url string
withBody ( $content , $contentType ) : $this
Attach a raw body to the request.
Parameters
- $content string
- $contentType string
asJson ( ) : $this
Indicate the request contains JSON.
asForm ( ) : $this
Indicate the request contains form parameters.
attach ( $name , $contents , $filename , array $headers ) : $this
Attach a file to the request.
Parameters
- $name string|array
- $contents string|resource
- $filename string|null
- $headers array
asMultipart ( ) : $this
Indicate the request is a multi-part form request.
bodyFormat ( string $format ) : $this
Specify the body format of the request.
Parameters
- $format string
withQueryParameters ( array $parameters ) : $this
Set the given query parameters in the request URI.
Parameters
- $parameters array
contentType ( string $contentType ) : $this
Specify the request's content type.
Parameters
- $contentType string
acceptJson ( ) : $this
Indicate that JSON should be returned by the server.
accept ( $contentType ) : $this
Indicate the type of content that should be returned by the server.
Parameters
- $contentType string
withHeaders ( array $headers ) : $this
Add the given headers to the request.
Parameters
- $headers array
withHeader ( $name , $value ) : $this
Add the given header to the request.
Parameters
- $name string
- $value mixed
replaceHeaders ( array $headers ) : $this
Replace the given headers on the request.
Parameters
- $headers array
withBasicAuth ( string $username , string $password ) : $this
Specify the basic authentication username and password for the request.
Parameters
- $username string
- $password string
withDigestAuth ( $username , $password ) : $this
Specify the digest authentication username and password for the request.
Parameters
- $username string
- $password string
withToken ( $token , $type ) : $this
Specify an authorization token for the request.
Parameters
- $token string
- $type string
withUserAgent ( $userAgent ) : $this
Specify the user agent for the request.
Parameters
- $userAgent string|bool
withUrlParameters ( array $parameters ) : $this
Specify the URL parameters that can be substituted into the request URL.
Parameters
- $parameters array
withCookies ( array $cookies , string $domain ) : $this
Specify the cookies that should be included with the request.
Parameters
- $cookies array
- $domain string
maxRedirects ( int $max ) : $this
Specify the maximum number of redirects to allow.
Parameters
- $max int
withoutRedirecting ( ) : $this
Indicate that redirects should not be followed.
withoutVerifying ( ) : $this
Indicate that TLS certificates should not be verified.
sink ( $to ) : $this
Specify the path where the body of the response should be stored.
Parameters
- $to string|resource
timeout ( int $seconds ) : $this
Specify the timeout (in seconds) for the request.
Parameters
- $seconds int
connectTimeout ( int $seconds ) : $this
Specify the connect timeout (in seconds) for the request.
Parameters
- $seconds int
retry ( int $times , $sleepMilliseconds , callable $when , bool $throw ) : $this
Specify the number of times the request should be attempted.
Parameters
- $times int
- $sleepMilliseconds Closure |int
- $when callable|null
- $throw bool
withOptions ( array $options ) : $this
Replace the specified options on the request.
Parameters
- $options array
withMiddleware ( callable $middleware ) : $this
Add new middleware the client handler stack.
Parameters
- $middleware callable
withRequestMiddleware ( callable $middleware ) : $this
Add new request middleware the client handler stack.
Parameters
- $middleware callable
withResponseMiddleware ( callable $middleware ) : $this
Add new response middleware the client handler stack.
Parameters
- $middleware callable
beforeSending ( $callback ) : $this
Add a new "before sending" callback to the request.
Parameters
- $callback callable
throw ( callable $callback ) : $this
Throw an exception if a server or client error occurs.
Parameters
- $callback callable|null
throwIf ( $condition ) : $this
Throw an exception if a server or client error occurred and the given condition evaluates to true.
Parameters
- $condition callable|bool
- $throwCallback callable|null
throwUnless ( $condition ) : $this
Throw an exception if a server or client error occurred and the given condition evaluates to false.
Parameters
- $condition bool
dump ( ) : $this
Dump the request before sending.
dd ( ) : $this
Dump the request before sending and end the script.
get ( string $url , $query ) : Response
Issue a GET request to the given URL.
Parameters
- $url string
- $query array|string|null
head ( string $url , $query ) : Response
Issue a HEAD request to the given URL.
Parameters
- $url string
- $query array|string|null
post ( string $url , $data ) : Response
Issue a POST request to the given URL.
Parameters
- $url string
- $data array
patch ( string $url , $data ) : Response
Issue a PATCH request to the given URL.
Parameters
- $url string
- $data array
put ( string $url , $data ) : Response
Issue a PUT request to the given URL.
Parameters
- $url string
- $data array
delete ( string $url , $data ) : Response
Issue a DELETE request to the given URL.
Parameters
- $url string
- $data array
pool ( callable $callback ) : array
Send a pool of asynchronous requests concurrently.
Parameters
- $callback callable
send ( string $method , string $url , array $options ) : Response
Send the request to the given URL.
Parameters
- $method string
- $url string
- $options array
expandUrlParameters ( string $url ) : string
Substitute the URL parameters in the given URL.
Parameters
- $url string
parseHttpOptions ( array $options ) : array
Parse the given HTTP options and set the appropriate additional options.
Parameters
- $options array
parseMultipartBodyFormat ( array $data ) : array|array[]
Parse multi-part form data.
Parameters
- $data array
makePromise ( string $method , string $url , array $options ) : GuzzleHttp\...\PromiseInterface
Send an asynchronous request to the given URL.
Parameters
- $method string
- $url string
- $options array
sendRequest ( string $method , string $url , array $options ) : Psr\...\MessageInterface|GuzzleHttp\...\PromiseInterface
Send a request either synchronously or asynchronously.
Parameters
- $method string
- $url string
- $options array
parseRequestData ( $method , $url , array $options ) : array
Get the request data as an array so that we can attach it to the request for convenient assertions.
Parameters
- $method string
- $url string
- $options array
populateResponse ( Response $response ) : Response
Populate the given response with additional data.
Parameters
- $response Response
buildClient ( ) : GuzzleHttp\Client
Build the Guzzle client.
requestsReusableClient ( ) : bool
Determine if a reusable client is required.
getReusableClient ( ) : GuzzleHttp\Client
Retrieve a reusable Guzzle client.
createClient ( $handlerStack ) : GuzzleHttp\Client
Create new Guzzle client.
Parameters
- $handlerStack GuzzleHttp\HandlerStack
buildHandlerStack ( ) : GuzzleHttp\HandlerStack
Build the Guzzle client handler stack.
pushHandlers ( $handlerStack ) : GuzzleHttp\HandlerStack
Add the necessary handlers to the given handler stack.
Parameters
- $handlerStack GuzzleHttp\HandlerStack
sinkStubHandler ( $sink ) : Closure
Get the sink stub handler callback.
Parameters
- $sink string
runBeforeSendingCallbacks ( $request , array $options ) : GuzzleHttp\...\RequestInterface
Execute the "before sending" callbacks.
Parameters
- $request GuzzleHttp\...\RequestInterface
- $options array
mergeOptions ( $options ) : array
Replace the given options with the current request options.
Parameters
- $options array
stub ( $callback ) : $this
Register a stub callable that will intercept requests and be able to return stub responses.
Parameters
- $callback callable
preventStrayRequests ( $prevent ) : $this
Indicate that an exception should be thrown if any request is not faked.
Parameters
- $prevent bool
async ( bool $async ) : $this
Toggle asynchronicity in requests.
Parameters
- $async bool
getPromise ( ) : GuzzleHttp\...\PromiseInterface|null
Retrieve the pending request promise.
dispatchRequestSendingEvent ( ) : void
Dispatch the RequestSending event if a dispatcher is available.
dispatchResponseReceivedEvent ( Response $response ) : void
Dispatch the ResponseReceived event if a dispatcher is available.
Parameters
- $response Response
dispatchConnectionFailedEvent ( ) : void
Dispatch the ConnectionFailed event if a dispatcher is available.
setClient ( GuzzleHttp\Client $client ) : $this
Set the client instance.
Parameters
- $client GuzzleHttp\Client
setHandler ( $handler ) : $this
Create a new client instance using the given handler.
Parameters
- $handler callable
getOptions ( ) : array
Get the pending request options.