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

Response

Implements

Uses

Properties

protected

$response Psr\...\ResponseInterface

The underlying PSR response.

Default: null
protected

$decoded array

The decoded JSON response.

Default: null

Methods

public

__construct ( $response ) : void

Create a new response instance.

Parameters

  • $response Psr\...\MessageInterface
public

body ( ) : string

Get the body of the response.

public

json ( $key , $default ) : mixed

Get the JSON decoded body of the response as an array or scalar value.

Parameters

  • $key string|null
  • $default mixed
public

object ( ) : object

Get the JSON decoded body of the response as an object.

public

collect ( $key ) : Collection

Get the JSON decoded body of the response as a collection.

Parameters

  • $key string|null
public

Get a header from the response.

Parameters

  • $header string
public

headers ( ) : array

Get the headers from the response.

public

status ( ) : int

Get the status code of the response.

public

reason ( ) : string

Get the reason phrase of the response.

public

effectiveUri ( ) : Psr\...\UriInterface|null

Get the effective URI of the response.

public

successful ( ) : bool

Determine if the request was successful.

public

ok ( ) : bool

Determine if the response code was "OK".

public

redirect ( ) : bool

Determine if the response was a redirect.

public

unauthorized ( ) : bool

Determine if the response was a 401 "Unauthorized" response.

public

forbidden ( ) : bool

Determine if the response was a 403 "Forbidden" response.

public

failed ( ) : bool

Determine if the response indicates a client or server error occurred.

public

clientError ( ) : bool

Determine if the response indicates a client error occurred.

public

serverError ( ) : bool

Determine if the response indicates a server error occurred.

public

onError ( callable $callback ) : $this

Execute the given callback if there was a server or client error.

Parameters

  • $callback callable
public

cookies ( ) : GuzzleHttp\...\CookieJar

Get the response cookies.

public

handlerStats ( ) : array

Get the handler stats of the response.

public

close ( ) : $this

Close the stream and any underlying resources.

public

toPsrResponse ( ) : Psr\...\ResponseInterface

Get the underlying PSR response for the response.

public

toException ( ) : RequestException |null

Create an exception if a server or client error occurred.

public

throw ( ) : $this

Throw an exception if a server or client error occurred.

Parameters

public

throwIf ( $condition ) : $this

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

Parameters

  • $condition bool
public

offsetExists ( $offset ) : bool

Determine if the given offset exists.

Parameters

  • $offset string
public

offsetGet ( $offset ) : mixed

Get the value for a given offset.

Parameters

  • $offset string
public

offsetSet ( $offset , $value ) : void

Set the value at the given offset.

Parameters

  • $offset string
  • $value mixed
public

offsetUnset ( $offset ) : void

Unset the value at the given offset.

Parameters

  • $offset string
public

__toString ( ) : string

Get the body of the response.

public

__call ( $method , $parameters ) : mixed

Dynamically proxy other methods to the underlying response.

Parameters

  • $method string
  • $parameters array