1 | <?php |
||
8 | class Response { |
||
9 | |||
10 | /** Ordered chunks of the output buffer **/ |
||
11 | public $chunks = array(); |
||
12 | |||
13 | public $code = 200; |
||
14 | |||
15 | private $format; |
||
16 | private $req; |
||
17 | private $headers = array(); |
||
18 | |||
19 | /** Public constructor **/ |
||
20 | function __construct($request = null) { |
||
23 | |||
24 | /** |
||
25 | * Add string to output buffer. |
||
26 | */ |
||
27 | public function add($out) { |
||
31 | |||
32 | /** |
||
33 | * Flush output buffer to http client and end request |
||
34 | * |
||
35 | * @param $code |
||
36 | * HTTP response Code. Defaults to 200 |
||
37 | * @param $format |
||
38 | * Output mime type. Defaults to request format |
||
39 | */ |
||
40 | public function send($code = null, $format = null) { |
||
44 | |||
45 | /** |
||
46 | * Send output to client without ending the script |
||
47 | * |
||
48 | * @param integer $code |
||
49 | * HTTP response Code. Defaults to 200 |
||
50 | * @param string $format |
||
51 | * Output mime type. Defaults to request format |
||
52 | * |
||
53 | * @return Response current respons object, so you can chain method calls on a response object. |
||
54 | */ |
||
55 | public function flush($code = null, $format = null) { |
||
84 | |||
85 | protected function verifyResponseCode($code) { |
||
100 | |||
101 | /** |
||
102 | * Set output format. Common aliases like: xml, json, html and txt are supported and |
||
103 | * automatically converted to proper HTTP content type definitions. |
||
104 | */ |
||
105 | public function setFormat($format) { |
||
113 | |||
114 | public function getFormat() { |
||
117 | |||
118 | /** |
||
119 | * Add an HTTP header key/value pair |
||
120 | * |
||
121 | * $key string |
||
122 | * $val string |
||
123 | * |
||
124 | */ |
||
125 | public function addHeader($key, $val) { |
||
132 | |||
133 | /** |
||
134 | * Send headers to instruct browser not to cache this content |
||
135 | * See http://stackoverflow.com/a/2068407 |
||
136 | */ |
||
137 | public function disableBrowserCache() { |
||
143 | |||
144 | /** |
||
145 | * Send entire collection of headers if they haven't already been sent |
||
146 | */ |
||
147 | public function sendHeaders($noContentType = false) { |
||
157 | |||
158 | private function codes() { |
||
203 | |||
204 | } // end Request |