28 public static function header($headerField, $value,
$replace = null, $responseCode = null) {
29 self::$headers[trim ( $headerField )]=trim($value);
30 \header ( trim ( $headerField ) .
": " . trim ( $value ),
$replace, $responseCode );
39 if (\is_array ( $values )) {
40 $values = \implode (
", ", $values );
42 self::header ( $headerField, $values );
46 $value = $contentType;
47 if (isset ( $encoding ))
48 $value .=
' ;' . $encoding;
49 self::header (
'content-type', $value );
56 self::header (
'Cache-Control',
'no-cache, must-revalidate' );
57 self::header (
'Expires',
'Sat, 26 Jul 1997 05:00:00 GMT' );
66 return \headers_sent ();
73 self::header (
'Content-Type',
'application/json' );
77 return isset(self::$headers[
"Content-Type"]) && self::$headers[
"Content-Type"]===
'application/json';
86 public static function asHtml($encoding =
'utf-8') {
87 self::setContentType (
'text/html', $encoding );
96 public static function asXml($encoding =
'utf-8') {
97 self::setContentType (
'application/xml', $encoding );
106 public static function asText($encoding =
'utf-8') {
107 self::setContentType (
'plain/text', $encoding );
118 self::header (
'Accept', $value );
127 self::header (
'Access-Control-Allow-Origin', $origin );
136 self::_headerArray (
'Access-Control-Allow-Methods', $methods );
145 self::_headerArray (
'Access-Control-Allow-Headers',
$headers );
154 self::header (
'Authorization', $authorization );
163 \http_response_code ( $value );
172 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.