Headers
in package
The headers file allows an application to manipulate the headers of the response before sending them to the client.
Tags
Table of Contents
- $headers : mixed
- $states : mixed
- $status : mixed
- all() : mixed
- contentType() : mixed
- This method allows the application to define the content type it wishes to send with the response. It prevents the user from having to define the headers manually and automatically sets an adequate charset depending on the app's settings.
- cors() : CORS
- Manipulate these Header's CORS options. This returns a CORS object that can be used to define how applications running on clients on a different origin are allowed to interact with the resources on this server.
- get() : array<string|int, string>
- getReasonPhrase() : mixed
- getStatus() : mixed
- redirect() : mixed
- send() : mixed
- Send the headers to the client. Once the headers have been sent, the application can no longer manipulate the headers. This method must be called before any output is sent to the browser.
- set() : mixed
- status() : mixed
- unset() : $this
- Allows the application to remove a header from the current response. While this is usually not the case (applications shouldn't be fighting internally) it might be the case that your application needs to unset a header that was set earlier.
Properties
$headers
private
mixed
$headers
= array('Content-type' => ['text/html;charset=utf-8'], 'x-Powered-By' => ['Spitfire'], 'x-version' => ['0.1 Beta'])
$states
private
mixed
$states
= array(200 => '200 OK', 201 => '201 Created', 202 => '202 Accepted', 204 => '204 No content', 206 => '206 Partial Content', 301 => '301 Moved Permanently', 302 => '302 Found', 304 => '304 Not modified', 400 => '400 Invalid request', 401 => '401 Unauthorized', 403 => '403 Forbidden', 404 => '404 Not Found', 418 => '418 Im a teapot', 419 => '419 Page expired', 429 => '429 Too many requests', 451 => '451 Unavailable for legal reasons', 410 => '410 Gone', 416 => '416 Range not satisfiable', 500 => '500 Server Error', 501 => '501 Not implemented', 503 => '503 Service Unavailable')
$status
private
mixed
$status
= 200
Methods
all()
public
all() : mixed
Return values
mixed —contentType()
This method allows the application to define the content type it wishes to send with the response. It prevents the user from having to define the headers manually and automatically sets an adequate charset depending on the app's settings.
public
contentType(string $str) : mixed
Parameters
- $str : string
Return values
mixed —cors()
Manipulate these Header's CORS options. This returns a CORS object that can be used to define how applications running on clients on a different origin are allowed to interact with the resources on this server.
public
cors() : CORS
Return values
CORS —get()
public
get(mixed $header) : array<string|int, string>
Parameters
- $header : mixed
Return values
array<string|int, string> —getReasonPhrase()
public
getReasonPhrase() : mixed
Return values
mixed —getStatus()
public
getStatus() : mixed
Return values
mixed —redirect()
public
redirect(mixed $location[, mixed $status = 302 ]) : mixed
Parameters
- $location : mixed
- $status : mixed = 302
Return values
mixed —send()
Send the headers to the client. Once the headers have been sent, the application can no longer manipulate the headers. This method must be called before any output is sent to the browser.
public
send() : mixed
Usually Spitfire will buffer all the output, so this should usually not be an issue.
Return values
mixed —set()
public
set(mixed $header, mixed $value) : mixed
Parameters
- $header : mixed
- $value : mixed
Return values
mixed —status()
public
status([mixed $code = 200 ]) : mixed
Parameters
- $code : mixed = 200
Return values
mixed —unset()
Allows the application to remove a header from the current response. While this is usually not the case (applications shouldn't be fighting internally) it might be the case that your application needs to unset a header that was set earlier.
public
unset(type $header) : $this
Parameters
- $header : type