$chunked
$chunked :
Whether the response has been chunked or not
Response
__construct(string $body = '', integer $status_code = null, array $headers = array())
Constructor
Create a new AbstractResponse object with a dependency injected Headers instance
string | $body | The response body's content |
integer | $status_code | The status code |
array | $headers | The response header "hash" |
protocolVersion(string $protocol_version = null) : string|\app\framework\Component\Route\Klein\AbstractResponse
Get (or set) the HTTP protocol version
Simply calling this method without any arguments returns the current protocol version. Calling with an integer argument, however, attempts to set the protocol version to what was provided by the argument.
string | $protocol_version |
body(string $body = null) : string|\app\framework\Component\Route\Klein\AbstractResponse
Get (or set) the response's body content
Simply calling this method without any arguments returns the current response body. Calling with an argument, however, sets the response body to what was provided by the argument.
string | $body | The body content string |
status() : \app\framework\Component\Route\Klein\HttpStatus
Returns the status object
headers() : \app\framework\Component\Route\Klein\DataCollection\HeaderDataCollection
Returns the headers collection
cookies() : \app\framework\Component\Route\Klein\DataCollection\ResponseCookieDataCollection
Returns the cookies collection
code(integer $code = null) : integer|\app\framework\Component\Route\Klein\AbstractResponse
Get (or set) the HTTP response code
Simply calling this method without any arguments returns the current response code. Calling with an integer argument, however, attempts to set the response code to what was provided by the argument.
integer | $code | The HTTP status code to send |
prepend(string $content) : \app\framework\Component\Route\Klein\AbstractResponse
Prepend a string to the response's content body
string | $content | The string to prepend |
append(string $content) : \app\framework\Component\Route\Klein\AbstractResponse
Append a string to the response's content body
string | $content | The string to append |
requireUnlocked() : \app\framework\Component\Route\Klein\AbstractResponse
Require that the response is unlocked
Throws an exception if the response is locked, preventing any methods from mutating the response when its locked
If the response is locked
lock() : \app\framework\Component\Route\Klein\AbstractResponse
Lock the response from further modification
unlock() : \app\framework\Component\Route\Klein\AbstractResponse
Unlock the response from further modification
sendHeaders(boolean $cookies_also = true, boolean $override = false) : \app\framework\Component\Route\Klein\AbstractResponse
Send our HTTP headers
boolean | $cookies_also | Whether or not to also send the cookies after sending the normal headers |
boolean | $override | Whether or not to override the check if headers have already been sent |
sendCookies(boolean $override = false) : \app\framework\Component\Route\Klein\AbstractResponse
Send our HTTP response cookies
boolean | $override | Whether or not to override the check if headers have already been sent |
sendBody() : \app\framework\Component\Route\Klein\AbstractResponse
Send our body's contents
send(boolean $override = false) : \app\framework\Component\Route\Klein\AbstractResponse
Send the response and lock it
boolean | $override | Whether or not to override the check if the response has already been sent |
If the response has already been sent
chunk(string $str = null) : \app\framework\Component\Route\Klein\Response
Enable response chunking
string | $str | An optional string to send as a response "chunk" |
header(string $key, mixed $value) : \app\framework\Component\Route\Klein\AbstractResponse
Sets a response header
string | $key | The name of the HTTP response header |
mixed | $value | The value to set the header with |
cookie(string $key, string $value = '', integer $expiry = null, string $path = '/', string $domain = null, boolean $secure = false, boolean $httponly = false) : \app\framework\Component\Route\Klein\AbstractResponse
Sets a response cookie
string | $key | The name of the cookie |
string | $value | The value to set the cookie with |
integer | $expiry | The time that the cookie should expire |
string | $path | The path of which to restrict the cookie |
string | $domain | The domain of which to restrict the cookie |
boolean | $secure | Flag of whether the cookie should only be sent over a HTTPS connection |
boolean | $httponly | Flag of whether the cookie should only be accessible over the HTTP protocol |
noCache() : \app\framework\Component\Route\Klein\AbstractResponse
Tell the browser not to cache the response
redirect(string $url, integer $code = 302) : \app\framework\Component\Route\Klein\AbstractResponse
Redirects the request to another URL
string | $url | The URL to redirect to |
integer | $code | The HTTP status code to use for redirection |
dump(mixed $obj) : \app\framework\Component\Route\Klein\Response
Dump a variable
mixed | $obj | The variable to dump |
file(string $path, string $filename = null, string $mimetype = null) : \app\framework\Component\Route\Klein\Response
Sends a file
It should be noted that this method disables caching of the response by default, as dynamically created files responses are usually downloads of some type and rarely make sense to be HTTP cached
Also, this method removes any data/content that is currently in the response body and replaces it with the file's data
string | $path | The path of the file to send |
string | $filename | The file's name |
string | $mimetype | The MIME type of the file |
Thrown if the file could not be read
json(mixed $object, string $jsonp_prefix = null) : \app\framework\Component\Route\Klein\Response
Sends an object as json or jsonp by providing the padding prefix
It should be noted that this method disables caching of the response by default, as json responses are usually dynamic and rarely make sense to be HTTP cached
Also, this method removes any data/content that is currently in the response body and replaces it with the passed json encoded object
mixed | $object | The data to encode as JSON |
string | $jsonp_prefix | The name of the JSON-P function prefix |