| Fully Qualified Name: | CodeIgniter\HTTP\Response |
| Extends: | Message |
| Implements: | ResponseInterface |
Representation of an outgoing, getServer-side response.
Per the HTTP specification, this interface includes properties for each of the following:
| Name | Description | Defined By |
|---|---|---|
| __construct() | Constructor | Response |
| appendBody() | Appends data to the body of the current message. | Message |
| appendHeader() | Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess) | Message |
| deleteCookie() | Sets a cookie to be deleted when the response is sent. | Response |
| download() | Force a download. | Response |
| getBody() | Grabs the current body. | Response |
| getCookie() | Returns the cookie | Response |
| getHeader() | Returns a single header object. If multiple headers with the same name exist, then will return an array of header objects. | Message |
| getHeaderLine() | Retrieves a comma-separated string of the values for a single header. | Message |
| getHeaders() | Returns an array containing all headers. | Message |
| getJSON() | Returns the current body, converted to JSON is it isn't already. | Response |
| getProtocolVersion() | Returns the HTTP Protocol Version. | Message |
| getReason() | Gets the response response phrase associated with the status code. | Response |
| getStatusCode() | Gets the response status code. | Response |
| getXML() | Retrieves the current body into XML and returns it. | Response |
| hasCookie() | Checks to see if the Response has a specified cookie or not. | Response |
| hasHeader() | Determines whether a header exists. | Message |
| noCache() | Sets the appropriate headers to ensure this response is not cached by the browsers. | Response |
| populateHeaders() | Populates the $headers array with any headers the getServer knows about. | Message |
| prependHeader() | Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess) | Message |
| pretend() | Turns "pretend" mode on or off to aid in testing. | Response |
| redirect() | Perform a redirect to a new URL, in two flavors: header or location. | Response |
| removeHeader() | Removes a header from the list of headers we track. | Message |
| send() | Sends the output to the browser. | Response |
| sendBody() | Sends the Body of the message to the browser. | Response |
| sendHeaders() | Sends the headers of this HTTP request to the browser. | Response |
| setBody() | Sets the body of the current message. | Message |
| setCache() | A shortcut method that allows the developer to set all of the cache-control headers in one method call. | Response |
| setContentType() | Sets the Content Type header for this response with the mime type and, optionally, the charset. | Response |
| setCookie() | Set a cookie | Response |
| setDate() | Sets the date header | Response |
| setHeader() | Sets a header and it's value. | Message |
| setJSON() | Converts the $body into JSON and sets the Content Type header. | Response |
| setLastModified() | Sets the Last-Modified date header. | Response |
| setLink() | Set the Link Header | Response |
| setProtocolVersion() | Sets the HTTP protocol version. | Message |
| setStatusCode() | Return an instance with the specified status code and, optionally, reason phrase. | Response |
| setXML() | Converts $body into XML, and sets the correct Content-Type. | Response |
Constructor
| Parameter Name | Type | Description |
|---|---|---|
| $config | \App |
Returns:
Appends data to the body of the current message.
| Parameter Name | Type | Description |
|---|---|---|
| $data | ||
| $data |
Returns: \Message|\Response
Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess)
| Parameter Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | string |
Returns: \Message
Sets a cookie to be deleted when the response is sent.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string | |
| $domain | string | |
| $path | string | |
| $prefix | string |
Returns: $this
Force a download.
Generates the headers that force a download to happen. And sends the file to the browser.
| Parameter Name | Type | Description |
|---|---|---|
| $filename | string | The |
| $data | string|null | The |
| $setMime | bool | Whether |
Returns: \CodeIgniter\HTTP\DownloadResponse|null
Grabs the current body.
Returns: mixed|string
Returns the cookie
| Parameter Name | Type | Description |
|---|---|---|
| $name | string|null | |
| $prefix | string |
Returns: mixed
Returns a single header object. If multiple headers with the same name exist, then will return an array of header objects.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string |
Returns: array|\CodeIgniter\HTTP\Header
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.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string |
Returns: string
Returns an array containing all headers.
Returns: array An array of the request headers
Returns the current body, converted to JSON is it isn't already.
Returns: mixed|string
Returns the HTTP Protocol Version.
Returns: string
Gets the response response phrase associated with the status code.
Returns: string
Gets the response status code.
The status code is a 3-digit integer result code of the getServer's attempt to understand and satisfy the request.
Returns: int Status code.
Retrieves the current body into XML and returns it.
Returns: mixed|string
Checks to see if the Response has a specified cookie or not.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | string|null | |
| $prefix | string |
Returns: bool
Determines whether a header exists.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string |
Returns: bool
Sets the appropriate headers to ensure this response is not cached by the browsers.
Returns: \Response
Populates the $headers array with any headers the getServer knows about.
Returns:
Adds an additional header value to any headers that accept multiple values (i.e. are an array or implement ArrayAccess)
| Parameter Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | string |
Returns: \Message
Turns "pretend" mode on or off to aid in testing.
| Parameter Name | Type | Description |
|---|---|---|
| $pretend | bool |
Returns: $this
Perform a redirect to a new URL, in two flavors: header or location.
| Parameter Name | Type | Description |
|---|---|---|
| $uri | string | The |
| $method | string | |
| $code | int | The |
Returns: $this
Removes a header from the list of headers we track.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string |
Returns: \Message
Sends the output to the browser.
Returns: \Response
Sends the Body of the message to the browser.
Returns: \Response
Sends the headers of this HTTP request to the browser.
Returns: \Response
Sets the body of the current message.
| Parameter Name | Type | Description |
|---|---|---|
| $data | mixed |
Returns: \Message|\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:
| Parameter Name | Type | Description |
|---|---|---|
| $options | array |
Returns: \Response
Sets the Content Type header for this response with the mime type and, optionally, the charset.
| Parameter Name | Type | Description |
|---|---|---|
| $mime | string | |
| $charset | string |
Returns: \Response
Set a cookie
Accepts an arbitrary number of binds (up to 7) or an associative array in the first parameter containing all the values.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string|array | Cookie |
| $value | string | Cookie |
| $expire | string | Cookie |
| $domain | string | Cookie |
| $path | string | Cookie |
| $prefix | string | Cookie |
| $secure | bool | Whether |
| $httponly | bool | Whether |
Returns: $this
Sets the date header
| Parameter Name | Type | Description |
|---|---|---|
| $date | \DateTime |
Returns: \Response
Sets a header and it's value.
| Parameter Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | array|null|string |
Returns: \Message|\Response
Converts the $body into JSON and sets the Content Type header.
| Parameter Name | Type | Description |
|---|---|---|
| $body | array|string | |
| $unencoded |
Returns: $this
Sets the Last-Modified date header.
$date can be either a string representation of the date or, preferably, an instance of DateTime.
| Parameter Name | Type | Description |
|---|---|---|
| $date | \DateTime|string |
Returns: \Response
Set the Link Header
| Parameter Name | Type | Description |
|---|---|---|
| $pager | \CodeIgniter\Pager\PagerInterface |
Returns: \Response
Sets the HTTP protocol version.
| Parameter Name | Type | Description |
|---|---|---|
| $version | string |
Returns: \Message
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.
| Parameter Name | Type | Description |
|---|---|---|
| $code | int | The |
| $reason | string | The |
Returns: $this
Converts $body into XML, and sets the correct Content-Type.
| Parameter Name | Type | Description |
|---|---|---|
| $body | array|string |
Returns: $this