AWS SDK for PHP
  • Namespace
  • Class
  • Tree
  • Download

Namespaces

  • Aws
    • AutoScaling
      • Enum
      • Exception
    • CloudFormation
      • Enum
      • Exception
    • CloudFront
      • Enum
      • Exception
    • CloudFront_2012_05_05
    • CloudHsm
      • Exception
    • CloudSearch
      • Enum
      • Exception
    • CloudSearch_2011_02_01
    • CloudSearchDomain
      • Exception
    • CloudTrail
      • Exception
    • CloudWatch
      • Enum
      • Exception
    • CloudWatchLogs
      • Exception
    • CodeCommit
      • Exception
    • CodeDeploy
      • Exception
    • CodePipeline
      • Exception
    • CognitoIdentity
      • Exception
    • CognitoSync
      • Exception
    • Common
      • Client
      • Command
      • Credentials
      • Enum
      • Exception
        • Parser
      • Hash
      • InstanceMetadata
        • Waiter
      • Iterator
      • Model
        • MultipartUpload
      • Signature
      • Waiter
    • ConfigService
      • Exception
    • DataPipeline
      • Enum
      • Exception
    • DeviceFarm
      • Exception
    • DirectConnect
      • Enum
      • Exception
    • DirectoryService
      • Exception
    • DynamoDb
      • Enum
      • Exception
      • Model
        • BatchRequest
      • Session
        • LockingStrategy
    • DynamoDb_2011_12_05
    • DynamoDbStreams
      • Exception
    • Ec2
      • Enum
      • Exception
      • Iterator
    • Ecs
      • Exception
    • Efs
      • Exception
    • ElastiCache
      • Enum
      • Exception
    • ElasticBeanstalk
      • Enum
      • Exception
    • ElasticFileSystem
    • ElasticLoadBalancing
      • Exception
    • ElasticTranscoder
      • Exception
    • Emr
      • Enum
      • Exception
    • Glacier
      • Enum
      • Exception
      • Model
        • MultipartUpload
    • Iam
      • Enum
      • Exception
    • ImportExport
      • Enum
      • Exception
    • Kinesis
      • Enum
      • Exception
    • Kms
      • Exception
    • Lambda
      • Exception
    • MachineLearning
      • Exception
    • OpsWorks
      • Enum
      • Exception
    • Rds
      • Enum
      • Exception
    • Redshift
      • Enum
      • Exception
    • Route53
      • Enum
      • Exception
    • Route53Domains
      • Exception
    • S3
      • Command
      • Enum
      • Exception
        • Parser
      • Iterator
      • Model
        • MultipartUpload
      • Sync
    • Ses
      • Enum
      • Exception
    • SimpleDb
      • Exception
    • Sns
      • Exception
      • MessageValidator
        • Exception
    • Sqs
      • Enum
      • Exception
    • Ssm
      • Exception
    • StorageGateway
      • Enum
      • Exception
    • Sts
      • Exception
    • Support
      • Exception
    • Swf
      • Enum
      • Exception
    • WorkSpaces
      • Exception
  • 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
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP

Classes

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

Interfaces

  • EntityEnclosingRequestInterface
  • MessageInterface
  • PostFileInterface
  • RequestFactoryInterface
  • RequestInterface
NOTE: For Version 3 of the AWS SDK for PHP, please see the V3 User Guide and V3 API Reference.

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 Guzzle/Http/Message/Response.php

Methods summary

  • public static fromMessage ( string $message )

    Create a new Response based on a raw response message

  • public __construct ( string $statusCode, ToArrayInterface|array $headers = null, string|resource|EntityBodyInterface $body = null )

    Construct the response

  • public __toString ( )
  • public serialize ( )
  • public unserialize ( mixed $serialize )
  • public getBody ( bool $asString = false )

    Get the response entity body

  • public setBody ( EntityBodyInterface|string $body )

    Set the response entity body

  • public setProtocol ( string $protocol, string $version )

    Set the protocol and protocol version of the response

  • public getProtocol ( )

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

  • public getProtocolVersion ( )

    Get the HTTP protocol version

  • public getInfo ( string $key = null )

    Get a cURL transfer information

  • public setInfo ( array $info )

    Set the transfer information

  • public setStatus ( int $statusCode, string $reasonPhrase = '' )

    Set the response status

  • public getStatusCode ( )

    Get the response status code

  • public getMessage ( )

    Get the entire response as a string

  • public getRawHeaders ( )

    Get the the raw message headers as a string

  • public getReasonPhrase ( )

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

  • public getAcceptRanges ( )

    Get the Accept-Ranges HTTP header

  • public calculateAge ( )

    Calculate the age of the response

  • public getAge ( )

    Get the Age HTTP header

  • public getAllow ( )

    Get the Allow HTTP header

  • public isMethodAllowed ( string $method )

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

  • public getCacheControl ( )

    Get the Cache-Control HTTP header

  • public getConnection ( )

    Get the Connection HTTP header

  • public getContentEncoding ( )

    Get the Content-Encoding HTTP header

  • public getContentLanguage ( )

    Get the Content-Language HTTP header

  • public getContentLength ( )

    Get the Content-Length HTTP header

  • public getContentLocation ( )

    Get the Content-Location HTTP header

  • public getContentDisposition ( )

    Get the Content-Disposition HTTP header

  • public getContentMd5 ( )

    Get the Content-MD5 HTTP header

  • public getContentRange ( )

    Get the Content-Range HTTP header

  • public getContentType ( )

    Get the Content-Type HTTP header

  • public 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.

  • public getDate ( )

    Get the Date HTTP header

  • public getEtag ( )

    Get the ETag HTTP header

  • public getExpires ( )

    Get the Expires HTTP header

  • public getLastModified ( )

    Get the Last-Modified HTTP header

  • public getLocation ( )

    Get the Location HTTP header

  • public getPragma ( )

    Get the Pragma HTTP header

  • public getProxyAuthenticate ( )

    Get the Proxy-Authenticate HTTP header

  • public getRetryAfter ( )

    Get the Retry-After HTTP header

  • public getServer ( )

    Get the Server HTTP header

  • public getSetCookie ( )

    Get the Set-Cookie HTTP header

  • public getTrailer ( )

    Get the Trailer HTTP header

  • public getTransferEncoding ( )

    Get the Transfer-Encoding HTTP header

  • public getVary ( )

    Get the Vary HTTP header

  • public getVia ( )

    Get the Via HTTP header

  • public getWarning ( )

    Get the Warning HTTP header

  • public getWwwAuthenticate ( )

    Get the WWW-Authenticate HTTP header

  • public isClientError ( )

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

  • public isError ( )

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

  • public isInformational ( )

    Checks if HTTP Status code is Information (1xx)

  • public isRedirect ( )

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

  • public isServerError ( )

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

  • public isSuccessful ( )

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

  • public canCache ( )

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

  • public getMaxAge ( )

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

  • public isFresh ( )

    Check if the response is considered fresh.

  • public canValidate ( )

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

  • public 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).

  • public json ( )

    Parse the JSON response body and return an array

  • public xml ( )

    Parse the XML response body and return a \SimpleXMLElement.

  • public getRedirectCount ( )

    Get the redirect count of this response

  • public setEffectiveUrl ( string $url )

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

  • public getEffectiveUrl ( )

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

Methods detail

# public static Guzzle\Http\Message\Response|boolean
fromMessage( string $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\ToArrayInterface|array $headers = null, string|resource|Guzzle\Http\EntityBodyInterface $body = null )

Construct the response

Parameters

$statusCode
string
$statusCode The response status code (e.g. 200, 404, etc)
$headers
Guzzle\Common\ToArrayInterface|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

Overrides

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

Returns

string
# public
serialize( )

Implementation of

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

Implementation of

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

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

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

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)

Returns

string
# public string
getProtocolVersion( )

Get the HTTP protocol version

Returns

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

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

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

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

Returns

integer
# public string
getMessage( )

Get the entire response as a string

Returns

string
# public string
getRawHeaders( )

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

Returns

string
# public string
getAcceptRanges( )

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

Returns

integer
# public integer|null
getAge( )

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

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

Parameters

$method
string
$method Method to check

Returns

boolean
# public string
getCacheControl( )

Get the Cache-Control HTTP header

Returns

string
# public string
getConnection( )

Get the Connection HTTP header

Returns

string
# public string|null
getContentEncoding( )

Get the Content-Encoding HTTP header

Returns

string|null
# public string|null
getContentLanguage( )

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

Returns

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

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

Returns

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

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

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

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.

Parameters

$type
string
$type Content type to check against

Returns

boolean
# public string|null
getDate( )

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

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

Returns

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

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

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

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

Returns

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

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

Returns

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

Get the Set-Cookie HTTP header

Returns

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

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

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

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

Returns

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

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

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)

Returns

boolean
# public boolean
isError( )

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)

Returns

boolean
# public boolean
isRedirect( )

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

Returns

boolean
# public boolean
isServerError( )

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

Returns

boolean
# public boolean
isSuccessful( )

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

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

Returns

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

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.

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).

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

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.

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

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

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)

Parameters

$url
string
$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)

Returns

string

Methods inherited from Guzzle\Http\Message\AbstractMessage

addHeader(), addHeaders(), getHeader(), getHeaderLines(), getHeaders(), getParams(), hasHeader(), removeHeader(), setHeader(), setHeaderFactory(), setHeaders()

Magic methods summary

Properties summary

protected Guzzle\Http\EntityBodyInterface $body
#

The response body

protected string $reasonPhrase
#

The reason phrase of the response (human readable code)

protected string $statusCode
#

The status code of the response

protected array $info
#

Information about the request

protected string $effectiveUrl
#

The effective URL that returned this response

protected static array $cacheResponseCodes
#

Cacheable response codes (see RFC 2616:13.4)

Properties inherited from Guzzle\Http\Message\AbstractMessage

$headerFactory, $headers, $params, $protocol, $protocolVersion

AWS SDK for PHP API documentation generated by ApiGen 2.8.0