class Illuminate / Http / Client / PendingRequest
You are viewing an older version of the documentation. For the latest, please visit master documentation.

PendingRequest

Uses

Properties

protected

$factory Factory |null

The factory instance.

Default: null
protected

$client GuzzleHttp\Client

The Guzzle client instance.

Default: null
protected

$baseUrl string

The base URL for the request.

Default: ''
protected

$bodyFormat string

The request body format.

Default: null
protected

$pendingBody string

The raw body for the request.

Default: null
protected

$pendingFiles array

The pending files for the request.

Default: []
protected

$cookies array

The request cookies.

Default: null
protected

$transferStats

The transfer stats for the request.

\GuzzleHttp\TransferStats

Default: null
protected

$options array

The request options.

Default: []
protected

$tries int

The number of times to try the request.

Default: 1
protected

$retryDelay int

The number of milliseconds to wait between retries.

Default: 100
protected

$retryWhenCallback callable|null

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

Default: null
protected

$beforeSendingCallbacks Collection

The callbacks that should execute before the request is sent.

Default: null
protected

$stubCallbacks Collection |null

The stub callables that will handle requests.

Default: null
protected

$middleware Collection

The middleware callables added by users that will handle requests.

Default: null
protected

$async bool

Whether the requests should be asynchronous.

Default: false
protected

$promise GuzzleHttp\...\PromiseInterface

The pending request promise.

Default: null
protected

$request Request |null

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

Default: null
protected

$mergableOptions array

The Guzzle request options that are mergable via array_merge_recursive.

Default: array

Methods

public

__construct ( Factory $factory ) : void

Create a new HTTP Client instance.

Parameters

public

baseUrl ( string $url ) : $this

Set the base URL for the pending request.

Parameters

  • $url string
public

withBody ( $content , $contentType ) : $this

Attach a raw body to the request.

Parameters

  • $content string
  • $contentType string
public

asJson ( ) : $this

Indicate the request contains JSON.

public

asForm ( ) : $this

Indicate the request contains form parameters.

public

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
public

asMultipart ( ) : $this

Indicate the request is a multi-part form request.

public

bodyFormat ( string $format ) : $this

Specify the body format of the request.

Parameters

  • $format string
public

contentType ( string $contentType ) : $this

Specify the request's content type.

Parameters

  • $contentType string
public

acceptJson ( ) : $this

Indicate that JSON should be returned by the server.

public

accept ( $contentType ) : $this

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

Parameters

  • $contentType string
public

withHeaders ( array $headers ) : $this

Add the given headers to the request.

Parameters

  • $headers array
public

withBasicAuth ( string $username , string $password ) : $this

Specify the basic authentication username and password for the request.

Parameters

  • $username string
  • $password string
public

withDigestAuth ( $username , $password ) : $this

Specify the digest authentication username and password for the request.

Parameters

  • $username string
  • $password string
public

withToken ( $token , $type ) : $this

Specify an authorization token for the request.

Parameters

  • $token string
  • $type string
public

withUserAgent ( $userAgent ) : $this

Specify the user agent for the request.

Parameters

  • $userAgent string
public

withCookies ( array $cookies , string $domain ) : $this

Specify the cookies that should be included with the request.

Parameters

  • $cookies array
  • $domain string
public

withoutRedirecting ( ) : $this

Indicate that redirects should not be followed.

public

withoutVerifying ( ) : $this

Indicate that TLS certificates should not be verified.

public

sink ( $to ) : $this

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

Parameters

  • $to string|resource
public

timeout ( int $seconds ) : $this

Specify the timeout (in seconds) for the request.

Parameters

  • $seconds int
public

retry ( int $times , int $sleep , callable $when ) : $this

Specify the number of times the request should be attempted.

Parameters

  • $times int
  • $sleep int
  • $when callable|null
public

withOptions ( array $options ) : $this

Replace the specified options on the request.

Parameters

  • $options array
public

withMiddleware ( callable $middleware ) : $this

Add new middleware the client handler stack.

Parameters

  • $middleware callable
public

beforeSending ( $callback ) : $this

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

Parameters

  • $callback callable
public

dump ( ) : $this

Dump the request before sending.

public

dd ( ) : $this

Dump the request before sending and end the script.

public

get ( string $url , $query ) : Response

Issue a GET request to the given URL.

Parameters

  • $url string
  • $query array|string|null
public

Issue a HEAD request to the given URL.

Parameters

  • $url string
  • $query array|string|null
public

post ( string $url , array $data ) : Response

Issue a POST request to the given URL.

Parameters

  • $url string
  • $data array
public

patch ( $url , $data ) : Response

Issue a PATCH request to the given URL.

Parameters

  • $url string
  • $data array
public

put ( $url , $data ) : Response

Issue a PUT request to the given URL.

Parameters

  • $url string
  • $data array
public

delete ( $url , $data ) : Response

Issue a DELETE request to the given URL.

Parameters

  • $url string
  • $data array
public

pool ( callable $callback ) : array

Send a pool of asynchronous requests concurrently.

Parameters

  • $callback callable
public

send ( string $method , string $url , array $options ) : Response

Send the request to the given URL.

Parameters

  • $method string
  • $url string
  • $options array
protected

parseMultipartBodyFormat ( array $data ) : array|array[]

Parse multi-part form data.

Parameters

  • $data array
protected

makePromise ( string $method , string $url , array $options ) : GuzzleHttp\...\PromiseInterface

Send an asynchronous request to the given URL.

Parameters

  • $method string
  • $url string
  • $options array
protected

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
protected

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
protected

populateResponse ( Response $response ) : Response

Populate the given response with additional data.

Parameters

public

buildClient ( ) : GuzzleHttp\Client

Build the Guzzle client.

protected

requestsReusableClient ( ) : bool

Determine if a reusable client is required.

protected

getReusableClient ( ) : GuzzleHttp\Client

Retrieve a reusable Guzzle client.

public

createClient ( $handlerStack ) : GuzzleHttp\Client

Create new Guzzle client.

Parameters

  • $handlerStack GuzzleHttp\HandlerStack
public

buildHandlerStack ( ) : GuzzleHttp\HandlerStack

Build the Guzzle client handler stack.

public

pushHandlers ( $handlerStack ) : GuzzleHttp\HandlerStack

Add the necessary handlers to the given handler stack.

Parameters

  • $handlerStack GuzzleHttp\HandlerStack
public

buildBeforeSendingHandler ( ) : Closure

Build the before sending handler.

public

buildRecorderHandler ( ) : Closure

Build the recorder handler.

public

buildStubHandler ( ) : Closure

Build the stub handler.

protected

sinkStubHandler ( $sink ) : Closure

Get the sink stub handler callback.

Parameters

  • $sink string
public

runBeforeSendingCallbacks ( $request , array $options ) : GuzzleHttp\...\RequestInterface

Execute the "before sending" callbacks.

Parameters

  • $request GuzzleHttp\...\RequestInterface
  • $options array
public

mergeOptions ( $options ) : array

Replace the given options with the current request options.

Parameters

  • $options array
public

stub ( $callback ) : $this

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

Parameters

  • $callback callable
public

async ( bool $async ) : $this

Toggle asynchronicity in requests.

Parameters

  • $async bool
public

getPromise ( ) : GuzzleHttp\...\PromiseInterface|null

Retrieve the pending request promise.

protected

dispatchRequestSendingEvent ( ) : void

Dispatch the RequestSending event if a dispatcher is available.

protected

dispatchResponseReceivedEvent ( Response $response ) : void

Dispatch the ResponseReceived event if a dispatcher is available.

Parameters

protected

dispatchConnectionFailedEvent ( ) : void

Dispatch the ConnectionFailed event if a dispatcher is available.

public

setClient ( GuzzleHttp\Client $client ) : $this

Set the client instance.

Parameters

  • $client GuzzleHttp\Client
public

setHandler ( $handler ) : $this

Create a new client instance using the given handler.

Parameters

  • $handler callable
public

getOptions ( ) : array

Get the pending request options.