Docs For Class Zend_Http_Response

## Class Zend_Http_Response

Description

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.

- todo: add __toString()
- todo: remove the pass by reference on extractor methods
- todo: clean up!
- license: New BSD License
- copyright: Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)

Located in /Zend/Http/Response.php (line 38)

Variable Summary
string $body
int $code
array $headers
string $message
string $version
Method Summary
static string decodeChunkedBody (string $body)
static string decodeDeflate (string $body)
static string decodeGzip (string $body)
static string extractBody ( &$response_str, string $response_str)
static int extractCode ( &$response_str, string $response_str)
static array extractHeaders ( &$response_str, string $response_str)
static string extractMessage ( &$response_str, string $response_str)
static string extractVersion ( &$response_str, string $response_str)
static Zend_Http_Response factory (string $response_str)
static string|null responseCodeAsText (int $code, [boolean $http11 = true])
Zend_Http_Response __construct (int $code, array $headers, [string $body = null], [string $version = '1.1'], [string $message = null])
string asString ([string $br = "\n"])
string getBody ()
string|array|null getHeader (mixed $header)
array getHeaders ()
string getHeadersAsString ([boolean $status_line = true], [string $br = "\n"])
string getMessage ()
string getRawBody ()
int getStatus ()
string getVersion ()
boolean isError ()
boolean isRedirect ()
boolean isSuccessful ()
Variables
string $body (line 74)

The HTTP response body

- access: protected

int $code (line 52)

The HTTP response code

- access: protected

array $headers = array() (line 67)

The HTTP response headers array

- access: protected

string $message (line 60)

The HTTP response code as string (e.g. 'Not Found' for 404 or 'Internal Server Error' for 500)

- access: protected

string $version (line 45)

The HTTP version (1.0, 1.1)

- access: protected

Methods
static method decodeChunkedBody (line 521)

Decode a "chunked" transfer-encoded body and return the decoded text

- access: public

static string decodeChunkedBody (string $body)

- string $body

static method decodeDeflate (line 561)

Decode a zlib deflated message (when Content-encoding = deflate)

Currently requires PHP with zlib support

- access: public

static string decodeDeflate (string $body)

- string $body

static method decodeGzip (line 548)

Decode a gzip encoded message (when Content-encoding = gzip)

Currently requires PHP with zlib support

- access: public

static string decodeGzip (string $body)

- string $body

static method extractBody (line 507)

Extract the body from a response string

- access: public

static string extractBody ( &$response_str, string $response_str)

- string $response_str
- &$response_str

static method extractCode (line 416)

Extract the response code from a response string

- access: public

static int extractCode ( &$response_str, string $response_str)

- string $response_str
- &$response_str

static method extractHeaders (line 467)

Extract the headers from a response string

- access: public

static array extractHeaders ( &$response_str, string $response_str)

- string $response_str
- &$response_str

static method extractMessage (line 433)

Extract the HTTP message from a response

- access: public

static string extractMessage ( &$response_str, string $response_str)

- string $response_str
- &$response_str

static method extractVersion (line 450)

Extract the HTTP version from a response

- access: public

static string extractVersion ( &$response_str, string $response_str)

- string $response_str
- &$response_str

static method factory (line 572)

Create a new Zend_Http_Response object from a string

- access: public

static Zend_Http_Response factory (string $response_str)

- string $response_str

static method responseCodeAsText (line 349)

A convenience function that returns a text representation of HTTP response codes. Returns null for unknown codes.

Conforms to HTTP/1.1 as defined in RFC 2616 See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10 for reference

- access: public

static string|null responseCodeAsText (int $code, [boolean $http11 = true])

- int $code: HTTP response code
- boolean $http11: Use HTTP version 1.1

Constructor __construct (line 95)

HTTP response constructor

In most cases, you would use Zend_Http_Response::factory 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.

- access: public
- throws: Zend_Http_Exception

Zend_Http_Response __construct (int $code, array $headers, [string $body = null], [string $version = '1.1'], [string $message = null])

- int $code: Response code (200, 404, ...)
- array $headers: Headers array
- string $body: Response body
- string $version: HTTP version
- string $message: Response code as text

asString (line 333)

Get the entire response as string

- access: public

string asString ([string $br = "\n"])

- string $br: Line breaks (eg. "\n", "\r\n", "
  ")

getBody (line 189)

Get the response body as 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.

- access: public

string getBody ()
getHeader (line 288)

Get a specific header as string, or null if it is not set

- access: public

string|array|null getHeader (mixed $header)
getHeaders (line 277)

Get the response headers

- access: public

array getHeaders ()
getHeadersAsString (line 303)

Get all headers as string

- access: public

string getHeadersAsString ([boolean $status_line = true], [string $br = "\n"])

- boolean $status_line: Whether to return the first status line (IE "HTTP 200 OK")
- string $br: Line breaks (eg. "\n", "\r\n", "
  ")

getMessage (line 267)

Return a message describing the HTTP response code (Eg. "OK", "Not Found", "Moved Permanently")

- access: public

string getMessage ()
getRawBody (line 236)

Get the raw response body (as transfered "on wire") as string

If the body is encoded (with Transfer-Encoding, not content-encoding - IE "chunked" body), gzip compressed, etc. it will not be decoded.

- access: public

string getRawBody ()
getStatus (line 256)

Get the HTTP response status code

- access: public

int getStatus ()
getVersion (line 246)

Get the HTTP version of the response

- access: public

string getVersion ()
isError (line 137)

Check whether the response is an error

- access: public

boolean isError ()
isRedirect (line 167)

Check whether the response is a redirection

- access: public

boolean isRedirect ()
isSuccessful (line 152)

Check whether the response in successful

- access: public

boolean isSuccessful ()

Documentation generated on Sun, 29 Oct 2006 21:28:01 -0600 by phpDocumentor 1.3.0RC6