Zend_Http_Response represents an HTTP 1.0 / 1.1 response message. It includes easy access to all the response's different elemts, as well as some convenience methods for parsing and validating HTTP responses.
package | Zend_Http |
---|---|
subpackage | Response |
copyright | Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
license | New BSD License |
__construct(integer $code, array $headers, string $body= null
, string $version= '1.1'
, string $message= null
)
In most cases, you would use Zend_Http_Response::fromString to parse an HTTP response string and create a new Zend_Http_Response object.
NOTE: The constructor no longer accepts nulls or empty values for the code and headers and will throw an exception if the passed values do not form a valid HTTP responses.
If no message is passed, the message will be guessed according to the response code.
integer
Response code (200, 404, ...)
array
Headers array
string
Response body
string
HTTP version
string
Response code as text
\Zend_Http_Exception |
---|
__toString() : string
string
asString(string $br = "\r\n"
) : string
string
Line breaks (eg. "\n", "\r\n", "
")
string
decodeChunkedBody(string $body) : string
string
string
decodeDeflate(string $body) : string
Currently requires PHP with zlib support
string
string
decodeGzip(string $body) : string
Currently requires PHP with zlib support
string
string
extractBody(string $response_str) : string
string
string
extractCode(string $response_str) : integer
string
integer
extractHeaders(string $response_str) : array
string
array
extractMessage(string $response_str) : string
string
string
extractVersion(string $response_str) : string
string
string
fromString(string $response_str) : \Zend_Http_Response
string
\Zend_Http_Response
getBody() : string
This method returns the body of the HTTP response (the content), as it should be in it's readable version - that is, after decoding it (if it was decoded), deflating it (if it was gzip compressed), etc.
If you want to get the raw body (as transfered on wire) use $this->getRawBody() instead.
string
getHeader($header) : string | array | null
string
array
null
getHeaders() : array
array
getHeadersAsString(boolean $status_line= true
, string $br= "\n"
) : string
boolean
Whether to return the first status line (IE "HTTP 200 OK")
string
Line breaks (eg. "\n", "\r\n", "
")
string
getMessage() : string
string
getRawBody() : string
If the body is encoded (with Transfer-Encoding, not content-encoding - IE "chunked" body), gzip compressed, etc. it will not be decoded.
string
getStatus() : integer
integer
getVersion() : string
string
isError() : boolean
boolean
isRedirect() : boolean
boolean
isSuccessful() : boolean
boolean
responseCodeAsText(integer $code= null
, boolean $http11= true
) : string
Returns array of all codes, if $code is not specified.
Conforms to HTTP/1.1 as defined in RFC 2616 (except for 'Unknown') See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10 for reference
integer
HTTP response code
boolean
Use HTTP version 1.1
string
$body : string
$code : integer
$headers : array
array()
$version : string