The response object is a simple class that wraps the HTTP response data. There are two ways to create a response object, the first one is using a string containing the response and the other one is instantiating the ZendHttpResponse
class.
use ZendHttpResponse; $response = Response::fromString(<<<EOS HTTP/1.0 200 OK HeaderField1: header-field-value HeaderField2: header-field-value2 <html> <body> Hello World </body> </html> EOS); // OR $response = new Response(); $response->setStatusCode(Response::STATUS_CODE_200); $response->getHeaders()->addHeaders(array( 'HeaderField1' => 'header-field-value', 'HeaderField2' => 'header-field-value2', ); $response->setContent(<<<EOS <html> <body> Hello World </body> </html> EOS);
This class provides a few methods that are useful to manipulate or check the status of a response, the most important ones are as follows:
setStatusCode()
and getStatusCode()
isForbidden()
isNotFound()
isOk()
isServerError()
isRedirect()