HTTP response class

Contains a response from Requests::request()

package Requests

 Methods

Constructor

__construct() 

Is the response a redirect?

is_redirect() : boolean

Returns

booleanTrue if redirect (3xx status), false if not.

Throws an exception if the request was not successful

throw_for_status(boolean $allow_redirects = true

Parameters

$allow_redirects

boolean

Set to false to throw on a 3xx as well

Exceptions

\Requests_Exception If `$allow_redirects` is false, and code is 3xx (`response.no_redirects`)
\Requests_Exception_HTTP On non-successful status code. Exception class corresponds to code (e.g. {@see Requests_Exception_HTTP_404})

 Properties

 

Response body

$body : string

Default

''
 

Cookies from the request

$cookies : \Requests_Cookie_Jar

Default

array()
 

Headers, as an associative array

$headers : \Requests_Response_Headers

Default

array()
 

Previous requests (from redirects)

$history : array

Default

array()
 

Protocol version, false if non-blocking

$protocol_version : float | boolean

Default

false
 

Raw HTTP data from the transport

$raw : string

Default

''
 

Number of redirects the request used

$redirects : integer

Default

0
 

Status code, false if non-blocking

$status_code : integer | boolean

Default

false
 

Whether the request succeeded or not

$success : boolean

Default

false
 

URL requested

$url : string

Default

''