Overview

Namespaces

  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
    • Tests
      • Batch
      • Cache
      • Common
        • Cache
        • Exception
      • Http
        • Curl
        • Exception
        • Message
          • Header
      • Inflection
      • Iterator
      • Log
      • Message
      • Mock
      • Parser
        • Cookie
        • Message
      • Parsers
        • UriTemplate
      • Plugin
        • Async
        • Backoff
        • Cache
        • Cookie
          • CookieJar
        • CurlAuth
        • ErrorResponse
        • History
        • Log
        • Md5
        • Mock
        • Oauth
        • Redirect
      • Service
        • Builder
        • Command
          • LocationVisitor
            • Request
            • Response
        • Description
        • Exception
        • Mock
          • Command
            • Sub
          • Model
        • Resource
      • Stream
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • VivaPayments
      • Message
  • PHP

Classes

  • AbstractMessage
  • EntityEnclosingRequest
  • Header
  • PostFile
  • Request
  • RequestFactory
  • Response

Interfaces

  • EntityEnclosingRequestInterface
  • MessageInterface
  • PostFileInterface
  • RequestFactoryInterface
  • RequestInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class Response

Guzzle HTTP response object

Guzzle\Http\Message\AbstractMessage implements Guzzle\Http\Message\MessageInterface
Extended by Guzzle\Http\Message\Response implements Serializable
Namespace: Guzzle\Http\Message
Located at src/Guzzle/Http/Message/Response.php
Methods summary
public static Guzzle\Http\Message\Response|boolean
# fromMessage( string $message )

Create a new Response based on a raw response message

Create a new Response based on a raw response message

Parameters

$message
Response message

Returns

Guzzle\Http\Message\Response|boolean
Returns false on error
public
# __construct( string $statusCode, Guzzle\Common\ToArrayInterface|array $headers = null, string|resource|Guzzle\Http\EntityBodyInterface $body = null )

Construct the response

Construct the response

Parameters

$statusCode
The response status code (e.g. 200, 404, etc)
$headers
The response headers
$body
The body of the response

Throws

Guzzle\Http\Exception\BadResponseException
if an invalid response code is given

Overrides

Guzzle\Http\Message\AbstractMessage::__construct()
public string
# __toString( )

Returns

string
public
# serialize( )

Implementation of

Serializable::serialize()
public
# unserialize( $serialize )

Implementation of

Serializable::unserialize()
public Guzzle\Http\EntityBodyInterface|string
# getBody( boolean $asString = false )

Get the response entity body

Get the response entity body

Parameters

$asString
Set to TRUE to return a string of the body rather than a full body object

Returns

Guzzle\Http\EntityBodyInterface|string
public Guzzle\Http\Message\Response
# setBody( Guzzle\Http\EntityBodyInterface|string $body )

Set the response entity body

Set the response entity body

Parameters

$body
Body to set

Returns

Guzzle\Http\Message\Response
public Guzzle\Http\Message\Response
# setProtocol( string $protocol, string $version )

Set the protocol and protocol version of the response

Set the protocol and protocol version of the response

Parameters

$protocol
Response protocol
$version
Protocol version

Returns

Guzzle\Http\Message\Response
public string
# getProtocol( )

Get the protocol used for the response (e.g. HTTP)

Get the protocol used for the response (e.g. HTTP)

Returns

string
public string
# getProtocolVersion( )

Get the HTTP protocol version

Get the HTTP protocol version

Returns

string
public array|string|null
# getInfo( string $key = null )

Get a cURL transfer information

Get a cURL transfer information

Parameters

$key
A single statistic to check

Returns

array|string|null

Returns all stats if no key is set, a single stat if a key is set, or null if a key is set and not found

Link

http://www.php.net/manual/en/function.curl-getinfo.php
public Guzzle\Http\Message\Response
# setInfo( array $info )

Set the transfer information

Set the transfer information

Parameters

$info
Array of cURL transfer stats

Returns

Guzzle\Http\Message\Response
public Guzzle\Http\Message\Response
# setStatus( integer $statusCode, string $reasonPhrase = '' )

Set the response status

Set the response status

Parameters

$statusCode
Response status code to set
$reasonPhrase
Response reason phrase

Returns

Guzzle\Http\Message\Response

Throws

Guzzle\Http\Exception\BadResponseException
when an invalid response code is received
public integer
# getStatusCode( )

Get the response status code

Get the response status code

Returns

integer
public string
# getMessage( )

Get the entire response as a string

Get the entire response as a string

Returns

string
public string
# getRawHeaders( )

Get the the raw message headers as a string

Get the the raw message headers as a string

Returns

string
public string
# getReasonPhrase( )

Get the response reason phrase- a human readable version of the numeric status code

Get the response reason phrase- a human readable version of the numeric status code

Returns

string
public string
# getAcceptRanges( )

Get the Accept-Ranges HTTP header

Get the Accept-Ranges HTTP header

Returns

string
Returns what partial content range types this server supports.
public integer
# calculateAge( )

Calculate the age of the response

Calculate the age of the response

Returns

integer
public integer|null
# getAge( )

Get the Age HTTP header

Get the Age HTTP header

Returns

integer|null
Returns the age the object has been in a proxy cache in seconds.
public string|null
# getAllow( )

Get the Allow HTTP header

Get the Allow HTTP header

Returns

string|null
Returns valid actions for a specified resource. To be used for a 405 Method not allowed.
public boolean
# isMethodAllowed( string $method )

Check if an HTTP method is allowed by checking the Allow response header

Check if an HTTP method is allowed by checking the Allow response header

Parameters

$method
Method to check

Returns

boolean
public string
# getCacheControl( )

Get the Cache-Control HTTP header

Get the Cache-Control HTTP header

Returns

string
public string
# getConnection( )

Get the Connection HTTP header

Get the Connection HTTP header

Returns

string
public string|null
# getContentEncoding( )

Get the Content-Encoding HTTP header

Get the Content-Encoding HTTP header

Returns

string|null
public string|null
# getContentLanguage( )

Get the Content-Language HTTP header

Get the Content-Language HTTP header

Returns

string|null
Returns the language the content is in.
public integer
# getContentLength( )

Get the Content-Length HTTP header

Get the Content-Length HTTP header

Returns

integer
Returns the length of the response body in bytes
public string|null
# getContentLocation( )

Get the Content-Location HTTP header

Get the Content-Location HTTP header

Returns

string|null
Returns an alternate location for the returned data (e.g /index.htm)
public string|null
# getContentDisposition( )

Get the Content-Disposition HTTP header

Get the Content-Disposition HTTP header

Returns

string|null
Returns the Content-Disposition header
public string|null
# getContentMd5( )

Get the Content-MD5 HTTP header

Get the Content-MD5 HTTP header

Returns

string|null
Returns a Base64-encoded binary MD5 sum of the content of the response.
public string
# getContentRange( )

Get the Content-Range HTTP header

Get the Content-Range HTTP header

Returns

string
Returns where in a full body message this partial message belongs (e.g. bytes 21010-47021/47022).
public string
# getContentType( )

Get the Content-Type HTTP header

Get the Content-Type HTTP header

Returns

string
Returns the mime type of this content.
public boolean
# isContentType( string $type )

Checks if the Content-Type is of a certain type. This is useful if the Content-Type header contains charset information and you need to know if the Content-Type matches a particular type.

Checks if the Content-Type is of a certain type. This is useful if the Content-Type header contains charset information and you need to know if the Content-Type matches a particular type.

Parameters

$type
Content type to check against

Returns

boolean
public string|null
# getDate( )

Get the Date HTTP header

Get the Date HTTP header

Returns

string|null
Returns the date and time that the message was sent.
public string|null
# getEtag( )

Get the ETag HTTP header

Get the ETag HTTP header

Returns

string|null
Returns an identifier for a specific version of a resource, often a Message digest.
public string|null
# getExpires( )

Get the Expires HTTP header

Get the Expires HTTP header

Returns

string|null
Returns the date/time after which the response is considered stale.
public string|null
# getLastModified( )

Get the Last-Modified HTTP header

Get the Last-Modified HTTP header

Returns

string|null

Returns the last modified date for the requested object, in RFC 2822 format (e.g. Tue, 15 Nov 1994 12:45:26 GMT)

public string|null
# getLocation( )

Get the Location HTTP header

Get the Location HTTP header

Returns

string|null
Used in redirection, or when a new resource has been created.
public Guzzle\Http\Message\Header|null
# getPragma( )

Get the Pragma HTTP header

Get the Pragma HTTP header

Returns

Guzzle\Http\Message\Header|null

Returns the implementation-specific headers that may have various effects anywhere along the request-response chain.

public string|null
# getProxyAuthenticate( )

Get the Proxy-Authenticate HTTP header

Get the Proxy-Authenticate HTTP header

Returns

string|null
Authentication to access the proxy (e.g. Basic)
public integer|null
# getRetryAfter( )

Get the Retry-After HTTP header

Get the Retry-After HTTP header

Returns

integer|null

If an entity is temporarily unavailable, this instructs the client to try again after a specified period of time.

public string|null
# getServer( )

Get the Server HTTP header

Get the Server HTTP header

Returns

string|null
A name for the server
public string|null
# getSetCookie( )

Get the Set-Cookie HTTP header

Get the Set-Cookie HTTP header

Returns

string|null
An HTTP cookie.
public string|null
# getTrailer( )

Get the Trailer HTTP header

Get the Trailer HTTP header

Returns

string|null

The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer-coding.

public string|null
# getTransferEncoding( )

Get the Transfer-Encoding HTTP header

Get the Transfer-Encoding HTTP header

Returns

string|null
The form of encoding used to safely transfer the entity to the user
public string|null
# getVary( )

Get the Vary HTTP header

Get the Vary HTTP header

Returns

string|null

Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather than requesting a fresh one from the origin server.

public string|null
# getVia( )

Get the Via HTTP header

Get the Via HTTP header

Returns

string|null
Informs the client of proxies through which the response was sent.
public string|null
# getWarning( )

Get the Warning HTTP header

Get the Warning HTTP header

Returns

string|null
A general warning about possible problems with the entity body
public string|null
# getWwwAuthenticate( )

Get the WWW-Authenticate HTTP header

Get the WWW-Authenticate HTTP header

Returns

string|null
Indicates the authentication scheme that should be used to access the requested entity
public boolean
# isClientError( )

Checks if HTTP Status code is a Client Error (4xx)

Checks if HTTP Status code is a Client Error (4xx)

Returns

boolean
public boolean
# isError( )

Checks if HTTP Status code is Server OR Client Error (4xx or 5xx)

Checks if HTTP Status code is Server OR Client Error (4xx or 5xx)

Returns

boolean
public boolean
# isInformational( )

Checks if HTTP Status code is Information (1xx)

Checks if HTTP Status code is Information (1xx)

Returns

boolean
public boolean
# isRedirect( )

Checks if HTTP Status code is a Redirect (3xx)

Checks if HTTP Status code is a Redirect (3xx)

Returns

boolean
public boolean
# isServerError( )

Checks if HTTP Status code is Server Error (5xx)

Checks if HTTP Status code is Server Error (5xx)

Returns

boolean
public boolean
# isSuccessful( )

Checks if HTTP Status code is Successful (2xx | 304)

Checks if HTTP Status code is Successful (2xx | 304)

Returns

boolean
public boolean
# canCache( )

Check if the response can be cached based on the response headers

Check if the response can be cached based on the response headers

Returns

boolean
Returns TRUE if the response can be cached or false if not
public integer|null
# getMaxAge( )

Gets the number of seconds from the current time in which this response is still considered fresh

Gets the number of seconds from the current time in which this response is still considered fresh

Returns

integer|null
Returns the number of seconds
public boolean|null
# isFresh( )

Check if the response is considered fresh.

Check if the response is considered fresh.

A response is considered fresh when its age is less than or equal to the freshness lifetime (maximum age) of the response.

Returns

boolean|null
public boolean
# canValidate( )

Check if the response can be validated against the origin server using a conditional GET request.

Check if the response can be validated against the origin server using a conditional GET request.

Returns

boolean
public integer
# getFreshness( )

Get the freshness of the response by returning the difference of the maximum lifetime of the response and the age of the response (max-age - age).

Get the freshness of the response by returning the difference of the maximum lifetime of the response and the age of the response (max-age - age).

Freshness values less than 0 mean that the response is no longer fresh and is ABS(freshness) seconds expired. Freshness values of greater than zero is the number of seconds until the response is no longer fresh. A NULL result means that no freshness information is available.

Returns

integer
public array|string|integer|boolean|float
# json( )

Parse the JSON response body and return an array

Parse the JSON response body and return an array

Returns

array|string|integer|boolean|float

Throws

RuntimeException
if the response body is not in JSON format
public SimpleXMLElement
# xml( )

Parse the XML response body and return a \SimpleXMLElement.

Parse the XML response body and return a \SimpleXMLElement.

In order to prevent XXE attacks, this method disables loading external entities. If you rely on external entities, then you must parse the XML response manually by accessing the response body directly.

Returns

SimpleXMLElement

Throws

RuntimeException
if the response body is not in XML format

Link

http://websec.io/2012/08/27/Preventing-XXE-in-PHP.html
public integer
# getRedirectCount( )

Get the redirect count of this response

Get the redirect count of this response

Returns

integer
public Guzzle\Http\Message\Response
# setEffectiveUrl( string $url )

Set the effective URL that resulted in this response (e.g. the last redirect URL)

Set the effective URL that resulted in this response (e.g. the last redirect URL)

Parameters

$url
The effective URL

Returns

Guzzle\Http\Message\Response
public string
# getEffectiveUrl( )

Get the effective URL that resulted in this response (e.g. the last redirect URL)

Get the effective URL that resulted in this response (e.g. the last redirect URL)

Returns

string
public
# getPreviousResponse( )

Deprecated

Codecoverageignore

public
# setRequest( $request )

Deprecated

Codecoverageignore

public
# getRequest( )

Deprecated

Codecoverageignore

Methods inherited from Guzzle\Http\Message\AbstractMessage
addCacheControlDirective(), addHeader(), addHeaders(), getCacheControlDirective(), getHeader(), getHeaderLines(), getHeaders(), getParams(), getTokenizedHeader(), hasCacheControlDirective(), hasHeader(), removeCacheControlDirective(), removeHeader(), setHeader(), setHeaderFactory(), setHeaders(), setTokenizedHeader()
Properties summary
protected Guzzle\Http\EntityBodyInterface $body

The response body

The response body

#
protected string $reasonPhrase

The reason phrase of the response (human readable code)

The reason phrase of the response (human readable code)

#
protected string $statusCode

The status code of the response

The status code of the response

#
protected array $info

Information about the request

Information about the request

# array()
protected string $effectiveUrl

The effective URL that returned this response

The effective URL that returned this response

#
protected static array $cacheResponseCodes

Cacheable response codes (see RFC 2616:13.4)

Cacheable response codes (see RFC 2616:13.4)

# array(200, 203, 206, 300, 301, 410)
Properties inherited from Guzzle\Http\Message\AbstractMessage
$headerFactory, $headers, $params, $protocol, $protocolVersion
Omnipay Viva Payments Gateway Module API Documentation API documentation generated by ApiGen