Zend_Http_Response provides easy access to an
HTTP responses message, as well as a set of static methods for
parsing HTTP response messages. Usually,
Zend_Http_Response is used as an object returned by a
Zend_Http_Client request.
In most cases, a Zend_Http_Response object will be instantiated
using the fromString() method, which reads a string containing a
HTTP response message, and returns a new
Zend_Http_Response object:
Example 488. Instantiating a Zend_Http_Response Object Using the Factory Method
<?php
$str = '';
$sock = fsockopen('www.example.com', 80);
$req = "GET / HTTP/1.1\r\n" .
"Host: www.example.com\r\n" .
"Connection: close\r\n" .
"\r\n";
fwrite($sock, $req);
while ($buff = fread($sock, 1024))
$str .= $sock;
$response = Zend_Http_Response::fromString($str);
You can also use the contractor method to create a new response object, by specifying all the parameters of the response:
public function __construct($code, $headers, $body = null, $version = '1.1', $message = null)
$code: The HTTP response code (eg. 200, 404, etc.)$headers: An associative array of HTTP response headers (eg. 'Host' => 'example.com')$body: The response body as a string$version: The HTTP response version (usually 1.0 or 1.1)$message: The HTTP response message (eg 'OK', 'Internal Server Error'). If not specified, the message will be set according to the response code




