Ubiquity 2.5.2
php rapid development framework
|
Http Response utilities. More...
Static Public Member Functions | |
static | header ($headerField, $value, bool $replace=true, int $responseCode=0) |
Send a raw HTTP header. | |
static | forward (string $url, bool $preserveUrl=true) |
Forwards to url using Location header. | |
static | setContentType ($contentType, $encoding=null) |
Sets header content-type. | |
static | noCache () |
Forces the disabling of the browser cache. | |
static | isSent (&$file=null, &$line=null) |
Checks if or where headers have been sent. | |
static | asJSON () |
Sets the response content-type to application/json. | |
static | isJSON () |
Tests if response content-type is application/json Only Works if UResponse has been used for setting headers. | |
static | asHtml ($encoding='utf-8') |
Sets the response content-type to text/html. | |
static | asXml ($encoding='utf-8') |
Sets the response content-type to application/xml. | |
static | asText ($encoding='utf-8') |
Sets the response content-type to plain/text. | |
static | setAccept ($value) |
Sets the Accept header. | |
static | enableCors ($origin=' *', $methods='GET, POST, PUT, DELETE, PATCH, OPTIONS', $headers='X-Requested-With, Content-Type, Accept, Origin, Authorization') |
Enables CORS. | |
static | setAccessControlOrigin ($origin=' *') |
Sets the Access-Control-Allow-Origin field value Only a single origin can be specified. | |
static | setAccessControlMethods ($methods) |
Sets the Access-Control-Allow-Methods field value. | |
static | setAccessControlHeaders ($headers) |
Sets the Access-Control-Allow-Headers field value. | |
static | setAuthorization ($authorization) |
Set the Authorization header field. | |
static | setResponseCode ($value) |
Sets the response code. | |
static | getResponseCode () |
Get the response code. | |
Static Public Attributes | |
static | $headers = [ ] |
Static Private Member Functions | |
static | _headerArray ($headerField, $values) |
Http Response utilities.
Ubiquity\utils\http$UResponse This class is part of Ubiquity
Definition at line 17 of file UResponse.php.
|
staticprivate |
string | $headerField | |
mixed | $values |
Definition at line 47 of file UResponse.php.
|
static |
Sets the response content-type to text/html.
string | $encoding | default: utf-8 |
Definition at line 108 of file UResponse.php.
|
static |
Sets the response content-type to application/json.
Definition at line 89 of file UResponse.php.
|
static |
Sets the response content-type to plain/text.
string | $encoding | default: utf-8 |
Definition at line 126 of file UResponse.php.
|
static |
Sets the response content-type to application/xml.
string | $encoding | default: utf-8 |
Definition at line 117 of file UResponse.php.
|
static |
Enables CORS.
string | $origin | The allowed origin (default: '*') |
string | $methods | The allowed methods (default: 'GET, POST, PUT, DELETE, PATCH, OPTIONS') |
string | $headers | The allowed headers (default: 'X-Requested-With, Content-Type, Accept, Origin, Authorization') |
Definition at line 148 of file UResponse.php.
|
static |
Forwards to url using Location header.
string | $url | |
bool | $preserveUrl |
Definition at line 38 of file UResponse.php.
|
static |
|
static |
Send a raw HTTP header.
string | $headerField | the header field |
string | $value | the header value |
boolean | $replace | The optional replace parameter indicates whether the header should replace a previous similar header |
int | $responseCode | Forces the HTTP response code to the specified value |
Definition at line 28 of file UResponse.php.
|
static |
Tests if response content-type is application/json Only Works if UResponse has been used for setting headers.
Definition at line 99 of file UResponse.php.
|
static |
Checks if or where headers have been sent.
string | $file | If the optional file and line parameters are set,headers_sent will put the PHP source file nameand line number where output started in the fileand line variables. |
int | $line | The line number where the output started. |
Definition at line 82 of file UResponse.php.
|
static |
Forces the disabling of the browser cache.
Definition at line 70 of file UResponse.php.
|
static |
Sets the Accept header.
string | $value | one of Http accept values |
Definition at line 136 of file UResponse.php.
|
static |
Sets the Access-Control-Allow-Headers field value.
string | array | $headers |
Definition at line 181 of file UResponse.php.
|
static |
Sets the Access-Control-Allow-Methods field value.
string | array | $methods |
Definition at line 172 of file UResponse.php.
|
static |
Sets the Access-Control-Allow-Origin field value Only a single origin can be specified.
string | $origin |
Definition at line 160 of file UResponse.php.
|
static |
Set the Authorization header field.
string | $authorization |
Definition at line 190 of file UResponse.php.
|
static |
Sets header content-type.
string | $contentType | |
string | $encoding |
Definition at line 60 of file UResponse.php.
|
static |
|
static |
Definition at line 18 of file UResponse.php.