1 | <?php |
||
35 | class HttpServletResponseWrapper extends ServletResponseWrapper implements HttpServletResponseInterface |
||
36 | { |
||
37 | |||
38 | /** |
||
39 | * Injects the passed response instance into this servlet response. |
||
40 | * |
||
41 | * @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $response The response instance used for initialization |
||
42 | * |
||
43 | * @return void |
||
44 | */ |
||
45 | 1 | public function injectHttpResponse(HttpServletResponseInterface $response) |
|
49 | |||
50 | /** |
||
51 | * Adds a cookie. |
||
52 | * |
||
53 | * @param \AppserverIo\Psr\HttpMessage\CookieInterface $cookie The cookie instance to add |
||
54 | * |
||
55 | * @return void |
||
56 | */ |
||
57 | public function addCookie(CookieInterface $cookie) |
||
61 | |||
62 | /** |
||
63 | * Returns TRUE if the response already has a cookie with the passed |
||
64 | * name, else FALSE. |
||
65 | * |
||
66 | * @param string $cookieName Name of the cookie to be checked |
||
67 | * |
||
68 | * @return boolean TRUE if the response already has the cookie, else FALSE |
||
69 | */ |
||
70 | public function hasCookie($cookieName) |
||
74 | |||
75 | /** |
||
76 | * Returns the cookie with the a cookie |
||
77 | * |
||
78 | * @param string $cookieName Name of the cookie to be checked |
||
79 | * |
||
80 | * @return \AppserverIo\Psr\HttpMessage\CookieInterface $cookie The cookie instance |
||
81 | */ |
||
82 | public function getCookie($cookieName) |
||
86 | |||
87 | /** |
||
88 | * Sets the headers |
||
89 | * |
||
90 | * @param array $headers The headers array |
||
91 | * |
||
92 | * @return void |
||
93 | */ |
||
94 | public function setHeaders(array $headers) |
||
98 | |||
99 | /** |
||
100 | * Returns the headers array |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | public function getHeaders() |
||
108 | |||
109 | /** |
||
110 | * Adds a header to array |
||
111 | * |
||
112 | * @param string $header The header label e.g. Accept or Content-Length |
||
113 | * @param string|int $value The header value |
||
114 | * |
||
115 | * @return void |
||
116 | */ |
||
117 | public function addHeader($header, $value) |
||
121 | |||
122 | /** |
||
123 | * Returns header info by given key |
||
124 | * |
||
125 | * @param string $key The headers key to return |
||
126 | * |
||
127 | * @return string|null |
||
128 | */ |
||
129 | public function getHeader($key) |
||
133 | |||
134 | /** |
||
135 | * Returns the headers as string |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | public function getHeadersAsString() |
||
143 | |||
144 | /** |
||
145 | * Removes one single header from the headers array. |
||
146 | * |
||
147 | * @param string $header The header to remove |
||
148 | * |
||
149 | * @return void |
||
150 | */ |
||
151 | public function removeHeader($header) |
||
155 | |||
156 | /** |
||
157 | * Checks if header exists by given name. |
||
158 | * |
||
159 | * @param string $name The header name to check |
||
160 | * |
||
161 | * @return boolean TRUE if the header is available, else FALSE |
||
162 | */ |
||
163 | public function hasHeader($name) |
||
167 | |||
168 | /** |
||
169 | * Returns the response that will be send back to the client. |
||
170 | * |
||
171 | * @return \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The response instance |
||
172 | */ |
||
173 | 1 | public function getResponse() |
|
177 | |||
178 | /** |
||
179 | * Returns Http response code number only. |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | 1 | public function getStatusCode() |
|
187 | |||
188 | /** |
||
189 | * Gets the response Reason-Phrase, a short textual description of the |
||
190 | * Status-Code. |
||
191 | * |
||
192 | * Because a Reason-Phrase is not a required element in response |
||
193 | * Status-Line, the Reason-Phrase value MAY be null. Implementations MAY |
||
194 | * choose to return the default RFC 2616 recommended reason phrase for the |
||
195 | * response's Status-Code. |
||
196 | * |
||
197 | * @return string|null Reason phrase, or null if unknown. |
||
198 | */ |
||
199 | public function getStatusReasonPhrase() |
||
203 | |||
204 | /** |
||
205 | * Returns response Http version. |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | public function getVersion() |
||
213 | |||
214 | /** |
||
215 | * Reset the body stream. |
||
216 | * |
||
217 | * @return void |
||
218 | */ |
||
219 | public function resetBodyStream() |
||
223 | |||
224 | /** |
||
225 | * Sets the HTTP response status code. |
||
226 | * |
||
227 | * @param integer $code The HTTP status code to set |
||
228 | * |
||
229 | * @return void |
||
230 | */ |
||
231 | public function setStatusCode($code) |
||
235 | |||
236 | /** |
||
237 | * Appends the content. |
||
238 | * |
||
239 | * @param string $content The content to append |
||
240 | * |
||
241 | * @return void |
||
242 | */ |
||
243 | public function appendBodyStream($content) |
||
247 | |||
248 | /** |
||
249 | * Copies a source stream to body stream. |
||
250 | * |
||
251 | * @param resource $sourceStream The file pointer to source stream |
||
252 | * @param integer $maxlength The max length to read from source stream |
||
253 | * @param integer $offset The offset from source stream to read |
||
254 | * |
||
255 | * @return integer The total number of bytes copied |
||
256 | */ |
||
257 | public function copyBodyStream($sourceStream, $maxlength = null, $offset = 0) |
||
261 | |||
262 | /** |
||
263 | * Returns the body content. |
||
264 | * |
||
265 | * @return string The boda content |
||
266 | */ |
||
267 | public function getBodyContent() |
||
271 | |||
272 | /** |
||
273 | * Returns the body stream as a resource. |
||
274 | * |
||
275 | * @return resource The body stream |
||
276 | */ |
||
277 | public function getBodyStream() |
||
281 | |||
282 | /** |
||
283 | * Returns the cookies. |
||
284 | * |
||
285 | * @return array The cookies |
||
286 | */ |
||
287 | public function getCookies() |
||
291 | |||
292 | /** |
||
293 | * Returns the exception bound to the response. |
||
294 | * |
||
295 | * @return \Exception|null The exception |
||
296 | */ |
||
297 | public function getException() |
||
301 | |||
302 | /** |
||
303 | * Returns the current state |
||
304 | * |
||
305 | * @return int |
||
306 | */ |
||
307 | public function getState() |
||
311 | |||
312 | /** |
||
313 | * Queries whether the response contains an exception or not. |
||
314 | * |
||
315 | * @return boolean TRUE if an exception has been attached, else FALSE |
||
316 | */ |
||
317 | public function hasException() |
||
321 | |||
322 | /** |
||
323 | * Compares current state with given state |
||
324 | * |
||
325 | * @param int $state The state to compare with |
||
326 | * |
||
327 | * @return bool Whether state is equal (true) or not (false) |
||
328 | */ |
||
329 | public function hasState($state) |
||
333 | |||
334 | /** |
||
335 | * Redirects to the passed URL by adding a 'Location' header and |
||
336 | * setting the appropriate status code, by default 301. |
||
337 | * |
||
338 | * @param string $url The URL to forward to |
||
339 | * @param integer $code The status code to set |
||
340 | * |
||
341 | * @return void |
||
342 | */ |
||
343 | public function redirect($url, $code = 301) |
||
347 | |||
348 | /** |
||
349 | * Resetss the stream resource pointing to body content. |
||
350 | * |
||
351 | * @param resource $bodyStream The body content stream resource |
||
352 | * |
||
353 | * @return void |
||
354 | */ |
||
355 | public function setBodyStream($bodyStream) |
||
359 | |||
360 | /** |
||
361 | * Binds the exception to the response. |
||
362 | * |
||
363 | * @param \Exception $exception The exception to bind. |
||
364 | * |
||
365 | * @return void |
||
366 | */ |
||
367 | public function setException(\Exception $exception) |
||
371 | |||
372 | /** |
||
373 | * Sets state of response |
||
374 | * |
||
375 | * @param int $state The state value |
||
376 | * |
||
377 | * @return void |
||
378 | */ |
||
379 | public function setState($state) |
||
383 | |||
384 | /** |
||
385 | * Sets the status reason phrase |
||
386 | * |
||
387 | * @param string $statusReasonPhrase The reason phrase |
||
388 | * |
||
389 | * @return void |
||
390 | */ |
||
391 | public function setStatusReasonPhrase($statusReasonPhrase) |
||
395 | } |
||
396 |