|
|
The Zend\Http\Response class is responsible for providing a
fluent API that allows a developer to interact with all the various parts of an HTTP
response.
A typical HTTP Response looks like this:
---------------------------
| VERSION | CODE | REASON |
---------------------------
| HEADERS |
---------------------------
| BODY |
---------------------------
The first line of the response consists of the HTTP version, status code, and the reason string for the provided status code; this is called the Response Line. Next is a set of headers; there can be 0 or an unlimited number of headers. The remainder of the response is the response body, which is typically a string of HTML that will render on the client's browser, but which can also be a place for request/response payload data typical of an AJAX request. More information on the structure and specification of an HTTP response can be found in » RFC-2616 on the W3.org site.
Response objects can either be created from the provided
fromString() factory, or, if you wish to have a completely
empty object to start with, by simply instantiating the
Zend\Http\Response class.
use Zend\Http\Response; $response = Response::fromString(<<Hello World

