20 public static function header($headerField, $value,
$replace=null, $responseCode=null) {
30 if (\is_array($values)) {
31 $values=\implode(
", ", $values);
33 self::header($headerField, $values);
39 $value.=
' ;' . $encoding;
40 self::header(
'content-type', $value);
47 self::header(
'Cache-Control',
'no-cache, must-revalidate');
48 self::header(
'Expires',
'Sat, 26 Jul 1997 05:00:00 GMT');
56 return \headers_sent();
63 self::header(
'Content-Type',
'application/json');
70 public static function asHtml($encoding=
'utf-8') {
71 self::setContentType(
'text/html', $encoding);
78 public static function asXml($encoding=
'utf-8') {
79 self::setContentType(
'application/xml', $encoding);
86 public static function asText($encoding=
'utf-8') {
87 self::setContentType(
'plain/text', $encoding);
96 self::header(
'Accept', $value);
104 self::header(
'Access-Control-Allow-Origin', $origin);
112 self::_headerArray(
'Access-Control-Allow-Methods', $origin);
120 self::_headerArray(
'Access-Control-Allow-Headers', $headers);
128 self::header(
'Authorization', $authorization);
136 \http_response_code($value);
144 return \http_response_code();
static setAccept($value)
Sets the Accept header.
static asJSON()
Sets the response content-type to application/json.
static asText($encoding='utf-8')
Sets the response content-type to plain/text.
static setAccessControlMethods($methods)
Sets the Access-Control-Allow-Methods field value.
static setAuthorization($authorization)
Set the Authorization header field.
static setContentType($contentType, $encoding=null)
static asHtml($encoding='utf-8')
Sets the response content-type to text/html.
static isSent()
Checks if or where headers have been sent.
static noCache()
Forces the disabling of the browser cache.
static getResponseCode()
Get the response code.
static setAccessControlHeaders($headers)
Sets the Access-Control-Allow-Headers field value.
static _headerArray($headerField, $values)
static setResponseCode($value)
Sets the response code.
static asXml($encoding='utf-8')
Sets the response content-type to application/xml.
static setAccessControlOrigin($origin)
Sets the Access-Control-Allow-Origin field value.
static header($headerField, $value, $replace=null, $responseCode=null)
Send a raw HTTP header.