Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • 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
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

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

Interfaces

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

Class Response

Guzzle HTTP response object

Guzzle\Http\Message\AbstractMessage implements Guzzle\Http\Message\MessageInterface
Extended by Guzzle\Http\Message\Response
Namespace: Guzzle\Http\Message
Located at 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
string
$message Response message

Returns

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

Construct the response

Construct the response

Parameters

$statusCode
string
$statusCode The response status code (e.g. 200, 404, etc)
$headers
Guzzle\Common\Collection|array
$headers The response headers
$body
string|resource|Guzzle\Http\EntityBodyInterface
$body The body of the response

Throws

Guzzle\Http\Exception\BadResponseException
if an invalid response code is given
public string
# __toString( )

Convert the response object to a string

Convert the response object to a string

Returns

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

Get the response entity body

Get the response entity body

Parameters

$asString
boolean
$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
Guzzle\Http\EntityBodyInterface|string
$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
string
$protocol Response protocol
$version
string
$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
string
$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
$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
integer
$statusCode Response status code to set
$reasonPhrase
string
$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 Guzzle\Http\Message\RequestInterface
# getRequest( )

Get the request object (or null) that is associated with this response

Get the request object (or null) that is associated with this response

Returns

Guzzle\Http\Message\RequestInterface
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|null
# getAge( boolean $headerOnly = false )

Get the Age HTTP header

Get the Age HTTP header

Parameters

$headerOnly
boolean
$headerOnly Set to TRUE to only retrieve the Age header rather than calculating the age

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
string
$method Method to check

Returns

boolean
public Guzzle\Http\Message\Header|null
# getCacheControl( )

Get the Cache-Control HTTP header

Get the Cache-Control HTTP header

Returns

Guzzle\Http\Message\Header|null
Returns a Header object that tells all caching mechanisms from server to client whether they may cache this object.
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
Returns the type of encoding used on the data. One of compress, deflate, gzip, identity.
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
string
$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 Guzzle\Http\Message\Header|null
# getSetCookie( )

Get the Set-Cookie HTTP header

Get the Set-Cookie HTTP header

Returns

Guzzle\Http\Message\Header|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. Currently defined methods are: chunked
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. (e.g. 1.0 fred, 1.1 nowhere.com (Apache/1.1))
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. (e.g. 199 Miscellaneous warning)
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 (e.g. Basic)
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 Guzzle\Http\Message\Response
# setRequest( Guzzle\Http\Message\RequestInterface $request )

Set the request object associated with the response

Set the request object associated with the response

Parameters

$request
Guzzle\Http\Message\RequestInterface
$request The request object used to generate the response

Returns

Guzzle\Http\Message\Response
public boolean
# canCache( )

Check if the response can be cached

Check if the response can be cached

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 null|Guzzle\Http\Message\Response
# getPreviousResponse( )

Get the previous response (e.g. Redirect response)

Get the previous response (e.g. Redirect response)

Returns

null|Guzzle\Http\Message\Response
public Guzzle\Http\Message\Response
# setPreviousResponse( Guzzle\Http\Message\Response $response )

Set the previous response

Set the previous response

Parameters

$response
Guzzle\Http\Message\Response
$response Response to set

Returns

Guzzle\Http\Message\Response
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

Guzzle\Common\Exception\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

Returns

SimpleXMLElement

Throws

Guzzle\Common\Exception\RuntimeException
if the response body is not in XML format
Methods inherited from Guzzle\Http\Message\AbstractMessage
addCacheControlDirective(), addHeader(), addHeaders(), changedHeader(), getCacheControlDirective(), getHeader(), getHeaderLines(), getHeaders(), getParams(), getTokenizedHeader(), hasCacheControlDirective(), hasHeader(), removeCacheControlDirective(), removeHeader(), setHeader(), 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 string $protocol 'HTTP'
#

Response protocol

Response protocol

protected array $info array()
#

Information about the request

Information about the request

protected Guzzle\Http\Message\RequestInterface $request null
#

Request object that may or may not be set

Request object that may or may not be set

protected array $cacheResponseCodes array(200, 203, 206, 300, 301, 410)
#

Cacheable response codes (see RFC 2616:13.4)

Cacheable response codes (see RFC 2616:13.4)

protected Guzzle\Http\Message\Response $previous
#

If a redirect was issued or an intermediate response was issued

If a redirect was issued or an intermediate response was issued

Properties inherited from Guzzle\Http\Message\AbstractMessage
$headers, $params, $protocolVersion
php-coveralls API documentation generated by ApiGen 2.8.0