Controller/Response/HttpTestCase.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Controller
- Version
- $Id: HttpTestCase.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Controller_Response_HttpTestCase
Zend_Controller_Response_HttpTestCase
HTTP response for controllers
- Parent(s)
- \Zend_Controller_Response_Http < \Zend_Controller_Response_Abstract
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- Uses
- \global\Zend_Controller_Response_Http
Properties

array $_body = array()Body content
Inherited from: \Zend_Controller_Response_Abstract::$$_body\Zend_Controller_Response_Http::$$_bodyarray()Details- Type
- array
- Inherited_from
- \Zend_Controller_Response_Abstract::$$_body
- Inherited_from
- \Zend_Controller_Response_Http::$$_body

\Exception $_exceptions = array()Exception stack
Inherited from: \Zend_Controller_Response_Abstract::$$_exceptions\Zend_Controller_Response_Http::$$_exceptionsarray()Details- Type
- \Exception
- Inherited_from
- \Zend_Controller_Response_Abstract::$$_exceptions
- Inherited_from
- \Zend_Controller_Response_Http::$$_exceptions

array $_headers = array()Array of headers.
Inherited from: \Zend_Controller_Response_Abstract::$$_headers\Zend_Controller_Response_Http::$$_headersEach header is an array with keys 'name' and 'value'
array()Details- Type
- array
- Inherited_from
- \Zend_Controller_Response_Abstract::$$_headers
- Inherited_from
- \Zend_Controller_Response_Http::$$_headers

array $_headersRaw = array()Array of raw headers.
Inherited from: \Zend_Controller_Response_Abstract::$$_headersRaw\Zend_Controller_Response_Http::$$_headersRawEach header is a single string, the entire header to emit
array()Details- Type
- array
- Inherited_from
- \Zend_Controller_Response_Abstract::$$_headersRaw
- Inherited_from
- \Zend_Controller_Response_Http::$$_headersRaw

int $_httpResponseCode = 200HTTP response code to use in headers
Inherited from: \Zend_Controller_Response_Abstract::$$_httpResponseCode\Zend_Controller_Response_Http::$$_httpResponseCode200Details- Type
- int
- Inherited_from
- \Zend_Controller_Response_Abstract::$$_httpResponseCode
- Inherited_from
- \Zend_Controller_Response_Http::$$_httpResponseCode

boolean $_isRedirect = falseFlag; is this response a redirect?
Inherited from: \Zend_Controller_Response_Abstract::$$_isRedirect\Zend_Controller_Response_Http::$$_isRedirectfalseDetails- Type
- boolean
- Inherited_from
- \Zend_Controller_Response_Abstract::$$_isRedirect
- Inherited_from
- \Zend_Controller_Response_Http::$$_isRedirect

boolean $_renderExceptions = falseWhether or not to render exceptions; off by default
Inherited from: \Zend_Controller_Response_Abstract::$$_renderExceptions\Zend_Controller_Response_Http::$$_renderExceptionsfalseDetails- Type
- boolean
- Inherited_from
- \Zend_Controller_Response_Abstract::$$_renderExceptions
- Inherited_from
- \Zend_Controller_Response_Http::$$_renderExceptions

boolean $headersSentThrowsException = trueFlag; if true, when header operations are called after headers have been sent, an exception will be raised; otherwise, processing will continue as normal.
Inherited from: \Zend_Controller_Response_Abstract::$$headersSentThrowsException\Zend_Controller_Response_Http::$$headersSentThrowsExceptionDefaults to true.
trueDetails- Type
- boolean
- Inherited_from
- \Zend_Controller_Response_Abstract::$$headersSentThrowsException
- Inherited_from
- \Zend_Controller_Response_Http::$$headersSentThrowsException
- See
- \global\canSendHeaders()
Methods

__toString() : stringMagic __toString functionality
Inherited from: \Zend_Controller_Response_Abstract::__toString()\Zend_Controller_Response_Http::__toString()Proxies to sendResponse() and returns response value as string using output buffering.
| Type | Description |
|---|---|
| string |

_normalizeHeader(string $name) : stringNormalize a header name
Inherited from: \Zend_Controller_Response_Abstract::_normalizeHeader()\Zend_Controller_Response_Http::_normalizeHeader()Normalizes a header name to X-Capitalized-Names
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| string |

append(string $name, string $content) : \Zend_Controller_Response_AbstractAppend a named body segment to the body content array
Inherited from: \Zend_Controller_Response_Abstract::append()\Zend_Controller_Response_Http::append()If segment already exists, replaces with $content and places at end of array.
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $content | string |
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

appendBody(string $content, null | string $name = null) : \Zend_Controller_Response_AbstractAppend content to the body content
Inherited from: \Zend_Controller_Response_Abstract::appendBody()\Zend_Controller_Response_Http::appendBody()| Name | Type | Description |
|---|---|---|
| $content | string | |
| $name | null | string |
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

canSendHeaders(bool $throw = false) : voidCan we send headers?
| Name | Type | Description |
|---|---|---|
| $throw | bool |
| Exception | Description |
|---|---|
| \Zend_Controller_Response_Exception |

clearAllHeaders() : \Zend_Controller_Response_AbstractClear all headers, normal and raw
Inherited from: \Zend_Controller_Response_Abstract::clearAllHeaders()\Zend_Controller_Response_Http::clearAllHeaders()| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

clearBody(string $name = null) : booleanClear body array
Inherited from: \Zend_Controller_Response_Abstract::clearBody()\Zend_Controller_Response_Http::clearBody()With no arguments, clears the entire body array. Given a $name, clears just that named segment; if no segment matching $name exists, returns false to indicate an error.
| Name | Type | Description |
|---|---|---|
| $name | string | Named segment to clear |
| Type | Description |
|---|---|
| boolean |

clearHeader(string $name) : \Zend_Controller_Response_AbstractClears the specified HTTP header
Inherited from: \Zend_Controller_Response_Abstract::clearHeader()\Zend_Controller_Response_Http::clearHeader()| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

clearHeaders() : \Zend_Controller_Response_AbstractClear headers
Inherited from: \Zend_Controller_Response_Abstract::clearHeaders()\Zend_Controller_Response_Http::clearHeaders()| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

clearRawHeader(string $headerRaw) : \Zend_Controller_Response_AbstractClears the specified raw HTTP header
Inherited from: \Zend_Controller_Response_Abstract::clearRawHeader()\Zend_Controller_Response_Http::clearRawHeader()| Name | Type | Description |
|---|---|---|
| $headerRaw | string |
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

clearRawHeaders() : \Zend_Controller_Response_AbstractClear all {@link setRawHeader() raw HTTP headers}
Inherited from: \Zend_Controller_Response_Abstract::clearRawHeaders()\Zend_Controller_Response_Http::clearRawHeaders()| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

getBody(bool | string $spec = false) : string | array | nullGet body and/or body segments
If $spec is false, returns the concatenated values of the body content array. If $spec is boolean true, returns the body content array. If $spec is a string and matches a named segment, returns the contents of that segment; otherwise, returns null.
| Name | Type | Description |
|---|---|---|
| $spec | bool | string |
| Type | Description |
|---|---|
| string | array | null |

getException() : arrayRetrieve the exception stack
Inherited from: \Zend_Controller_Response_Abstract::getException()\Zend_Controller_Response_Http::getException()| Type | Description |
|---|---|
| array |

getExceptionByCode(mixed $code) : voidRetrieve all exceptions of a given code
Inherited from: \Zend_Controller_Response_Abstract::getExceptionByCode()\Zend_Controller_Response_Http::getExceptionByCode()| Name | Type | Description |
|---|---|---|
| $code | mixed |

getExceptionByMessage(string $message) : false | arrayRetrieve all exceptions of a given message
Inherited from: \Zend_Controller_Response_Abstract::getExceptionByMessage()\Zend_Controller_Response_Http::getExceptionByMessage()| Name | Type | Description |
|---|---|---|
| $message | string |
| Type | Description |
|---|---|
| false | array |

getExceptionByType(string $type) : false | arrayRetrieve all exceptions of a given type
Inherited from: \Zend_Controller_Response_Abstract::getExceptionByType()\Zend_Controller_Response_Http::getExceptionByType()| Name | Type | Description |
|---|---|---|
| $type | string |
| Type | Description |
|---|---|
| false | array |

getHeaders() : arrayReturn array of headers; see {@link $_headers} for format
Inherited from: \Zend_Controller_Response_Abstract::getHeaders()\Zend_Controller_Response_Http::getHeaders()| Type | Description |
|---|---|
| array |

getHttpResponseCode() : intRetrieve HTTP response code
Inherited from: \Zend_Controller_Response_Abstract::getHttpResponseCode()\Zend_Controller_Response_Http::getHttpResponseCode()| Type | Description |
|---|---|
| int |

getRawHeaders() : arrayRetrieve all {@link setRawHeader() raw HTTP headers}
Inherited from: \Zend_Controller_Response_Abstract::getRawHeaders()\Zend_Controller_Response_Http::getRawHeaders()| Type | Description |
|---|---|
| array |

hasExceptionOfCode(int $code) : booleanDoes the response object contain an exception with a given code?
Inherited from: \Zend_Controller_Response_Abstract::hasExceptionOfCode()\Zend_Controller_Response_Http::hasExceptionOfCode()| Name | Type | Description |
|---|---|---|
| $code | int |
| Type | Description |
|---|---|
| boolean |

hasExceptionOfMessage(string $message) : booleanDoes the response object contain an exception with a given message?
Inherited from: \Zend_Controller_Response_Abstract::hasExceptionOfMessage()\Zend_Controller_Response_Http::hasExceptionOfMessage()| Name | Type | Description |
|---|---|---|
| $message | string |
| Type | Description |
|---|---|
| boolean |

hasExceptionOfType(string $type) : booleanDoes the response object contain an exception of a given type?
Inherited from: \Zend_Controller_Response_Abstract::hasExceptionOfType()\Zend_Controller_Response_Http::hasExceptionOfType()| Name | Type | Description |
|---|---|---|
| $type | string |
| Type | Description |
|---|---|
| boolean |

insert(string $name, string $content, string $parent = null, boolean $before = false) : \Zend_Controller_Response_AbstractInsert a named segment into the body content array
Inherited from: \Zend_Controller_Response_Abstract::insert()\Zend_Controller_Response_Http::insert()| Name | Type | Description |
|---|---|---|
| $name | string | |
| $content | string | |
| $parent | string | |
| $before | boolean | Whether to insert the new segment before or after the parent. Defaults to false (after) |
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

isException() : booleanHas an exception been registered with the response?
Inherited from: \Zend_Controller_Response_Abstract::isException()\Zend_Controller_Response_Http::isException()| Type | Description |
|---|---|
| boolean |

isRedirect() : booleanIs this a redirect?
Inherited from: \Zend_Controller_Response_Abstract::isRedirect()\Zend_Controller_Response_Http::isRedirect()| Type | Description |
|---|---|
| boolean |

prepend(string $name, string $content) : voidPrepend a named body segment to the body content array
Inherited from: \Zend_Controller_Response_Abstract::prepend()\Zend_Controller_Response_Http::prepend()If segment already exists, replaces with $content and places at top of array.
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $content | string |

renderExceptions(boolean $flag = null) : booleanWhether or not to render exceptions (off by default)
Inherited from: \Zend_Controller_Response_Abstract::renderExceptions()\Zend_Controller_Response_Http::renderExceptions()If called with no arguments or a null argument, returns the value of the flag; otherwise, sets it and returns the current value.
| Name | Type | Description |
|---|---|---|
| $flag | boolean | Optional |
| Type | Description |
|---|---|
| boolean |

sendHeaders() : array"send" headers by returning array of all headers that would be sent
Sends any headers specified. If an HTTP response code has been specified, it is sent with the first header.
| Type | Description |
|---|---|
| array |

sendResponse() : string"send" Response
Concats all response headers, and then final body (separated by two newlines)
| Type | Description |
|---|---|
| string |

setBody(string $content, null | string $name = null) : \Zend_Controller_Response_AbstractSet body content
Inherited from: \Zend_Controller_Response_Abstract::setBody()\Zend_Controller_Response_Http::setBody()If $name is not passed, or is not a string, resets the entire body and sets the 'default' key to $content.
If $name is a string, sets the named segment in the body array to $content.
| Name | Type | Description |
|---|---|---|
| $content | string | |
| $name | null | string |
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

setException(\Exception $e) : \Zend_Controller_Response_AbstractRegister an exception with the response
Inherited from: \Zend_Controller_Response_Abstract::setException()\Zend_Controller_Response_Http::setException()| Name | Type | Description |
|---|---|---|
| $e | \Exception |
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

setHeader(string $name, string $value, boolean $replace = false) : \Zend_Controller_Response_AbstractSet a header
Inherited from: \Zend_Controller_Response_Abstract::setHeader()\Zend_Controller_Response_Http::setHeader()If $replace is true, replaces any headers already defined with that $name.
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | string | |
| $replace | boolean |
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

setHttpResponseCode(int $code) : \Zend_Controller_Response_AbstractSet HTTP response code to use with headers
Inherited from: \Zend_Controller_Response_Abstract::setHttpResponseCode()\Zend_Controller_Response_Http::setHttpResponseCode()| Name | Type | Description |
|---|---|---|
| $code | int |
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

setRawHeader(string $value) : \Zend_Controller_Response_AbstractSet raw HTTP header
Inherited from: \Zend_Controller_Response_Abstract::setRawHeader()\Zend_Controller_Response_Http::setRawHeader()Allows setting non key => value headers, such as status codes
| Name | Type | Description |
|---|---|---|
| $value | string |
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |

setRedirect(string $url, int $code = 302) : \Zend_Controller_Response_AbstractSet redirect URL
Inherited from: \Zend_Controller_Response_Abstract::setRedirect()\Zend_Controller_Response_Http::setRedirect()Sets Location header and response code. Forces replacement of any prior redirects.
| Name | Type | Description |
|---|---|---|
| $url | string | |
| $code | int |
| Type | Description |
|---|---|
| \Zend_Controller_Response_Abstract |