$CSP
$CSP : \CodeIgniter\HTTP\ContentSecurityPolicy
Content security policy handler
Representation of an outgoing, getServer-side response.
Per the HTTP specification, this interface includes properties for each of the following:
setBody( $data) : \CodeIgniter\HTTP\Message|\CodeIgniter\HTTP\Response
Sets the body of the current message.
$data |
appendBody( $data) : \CodeIgniter\HTTP\Message|\CodeIgniter\HTTP\Response
Appends data to the body of the current message.
$data |
getHeader(string $name) : array|\CodeIgniter\HTTP\Header
Returns a single header object. If multiple headers with the same name exist, then will return an array of header objects.
string | $name |
getHeaderLine(string $name) : string
Retrieves a comma-separated string of the values for a single header.
This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma.
NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating.
string | $name |
setHeader(string $name, array|null|string $value) : \CodeIgniter\HTTP\Message|\CodeIgniter\HTTP\Response
Sets a header and it's value.
string | $name | |
array|null|string | $value |
removeHeader(string $name) : \CodeIgniter\HTTP\Message
Removes a header from the list of headers we track.
string | $name |
appendHeader(string $name, string $value) : \CodeIgniter\HTTP\Message
Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess)
string | $name | |
string | $value |
prependHeader(string $name, string $value) : \CodeIgniter\HTTP\Message
Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess)
string | $name | |
string | $value |
setProtocolVersion(string $version) : \CodeIgniter\HTTP\Message
Sets the HTTP protocol version.
string | $version |
__construct(\Config\App $config)
Constructor
\Config\App | $config |
setStatusCode(integer $code, string $reason = '') : $this
Return an instance with the specified status code and, optionally, reason phrase.
If no reason phrase is specified, will default recommended reason phrase for the response's status code.
integer | $code | The 3-digit integer result code to set. |
string | $reason | The reason phrase to use with the provided status code; if none is provided, will default to the IANA name. |
For invalid status code arguments.
setDate(\DateTime $date) : \CodeIgniter\HTTP\Response
Sets the date header
\DateTime | $date |
setLink(\CodeIgniter\Pager\PagerInterface $pager) : \CodeIgniter\HTTP\Response
Set the Link Header
\CodeIgniter\Pager\PagerInterface | $pager |
setContentType(string $mime, string $charset = 'UTF-8') : \CodeIgniter\HTTP\Response
Sets the Content Type header for this response with the mime type and, optionally, the charset.
string | $mime | |
string | $charset |
noCache() : \CodeIgniter\HTTP\Response
Sets the appropriate headers to ensure this response is not cached by the browsers.
setCache(array $options = array()) : \CodeIgniter\HTTP\Response
A shortcut method that allows the developer to set all of the cache-control headers in one method call.
The options array is used to provide the cache-control directives for the header. It might look something like:
$options = [
'max-age' => 300,
's-maxage' => 900
'etag' => 'abcde',
];
Typical options are:
array | $options |
setLastModified(\DateTime|string $date) : \CodeIgniter\HTTP\Response
Sets the Last-Modified date header.
$date can be either a string representation of the date or, preferably, an instance of DateTime.
\DateTime|string | $date |
send() : \CodeIgniter\HTTP\Response
Sends the output to the browser.
sendHeaders() : \CodeIgniter\HTTP\Response
Sends the headers of this HTTP request to the browser.
sendBody() : \CodeIgniter\HTTP\Response
Sends the Body of the message to the browser.
redirect(string $uri, string $method = 'auto', integer $code = null) : $this
Perform a redirect to a new URL, in two flavors: header or location.
string | $uri | The URI to redirect to |
string | $method | |
integer | $code | The type of redirection, defaults to 302 |
For invalid status code.
setCookie(string|array $name, string $value = '', string $expire = '', string $domain = '', string $path = '/', string $prefix = '', boolean|false $secure = false, boolean|false $httponly = false) : $this
Set a cookie
Accepts an arbitrary number of binds (up to 7) or an associative array in the first parameter containing all the values.
string|array | $name | Cookie name or array containing binds |
string | $value | Cookie value |
string | $expire | Cookie expiration time in seconds |
string | $domain | Cookie domain (e.g.: '.yourdomain.com') |
string | $path | Cookie path (default: '/') |
string | $prefix | Cookie name prefix |
boolean|false | $secure | Whether to only transfer cookies via SSL |
boolean|false | $httponly | Whether only make the cookie accessible via HTTP (no javascript) |
download(string $filename = '', string|null $data = '', boolean $setMime = false) : \CodeIgniter\HTTP\DownloadResponse|null
Force a download.
Generates the headers that force a download to happen. And sends the file to the browser.
string | $filename | The path to the file to send |
string|null | $data | The data to be downloaded |
boolean | $setMime | Whether to try and send the actual MIME type |
formatBody(string|array $body, string $format) : mixed
Handles conversion of the of the data into the appropriate format, and sets the correct Content-Type header for our response.
string|array | $body | |
string | $format | Valid: json, xml |
If the body property is not string or array.