Ubiquity  2.0.3
php rapid development framework
UResponse Class Reference

Http Response utilities. More...

Static Public Member Functions

static header ($headerField, $value, $replace=null, $responseCode=null)
 Send a raw HTTP header. More...
 
static setContentType ($contentType, $encoding=null)
 
static noCache ()
 Forces the disabling of the browser cache. More...
 
static isSent ()
 Checks if or where headers have been sent. More...
 
static asJSON ()
 Sets the response content-type to application/json. More...
 
static isJSON ()
 
static asHtml ($encoding='utf-8')
 Sets the response content-type to text/html. More...
 
static asXml ($encoding='utf-8')
 Sets the response content-type to application/xml. More...
 
static asText ($encoding='utf-8')
 Sets the response content-type to plain/text. More...
 
static setAccept ($value)
 Sets the Accept header. More...
 
static setAccessControlOrigin ($origin)
 Sets the Access-Control-Allow-Origin field value. More...
 
static setAccessControlMethods ($methods)
 Sets the Access-Control-Allow-Methods field value. More...
 
static setAccessControlHeaders ($headers)
 Sets the Access-Control-Allow-Headers field value. More...
 
static setAuthorization ($authorization)
 Set the Authorization header field. More...
 
static setResponseCode ($value)
 Sets the response code. More...
 
static getResponseCode ()
 Get the response code. More...
 

Static Public Attributes

static $headers =[]
 

Static Private Member Functions

static _headerArray ($headerField, $values)
 

Detailed Description

Http Response utilities.

Author
jc
Version
1.0.0.0

Definition at line 12 of file UResponse.php.

Member Function Documentation

◆ _headerArray()

static _headerArray (   $headerField,
  $values 
)
staticprivate
Parameters
string$headerField
mixed$values

Definition at line 38 of file UResponse.php.

◆ asHtml()

static asHtml (   $encoding = 'utf-8')
static

Sets the response content-type to text/html.

Parameters
string$encodingdefault: utf-8

Definition at line 86 of file UResponse.php.

◆ asJSON()

static asJSON ( )
static

Sets the response content-type to application/json.

Definition at line 72 of file UResponse.php.

◆ asText()

static asText (   $encoding = 'utf-8')
static

Sets the response content-type to plain/text.

Parameters
string$encodingdefault: utf-8

Definition at line 106 of file UResponse.php.

◆ asXml()

static asXml (   $encoding = 'utf-8')
static

Sets the response content-type to application/xml.

Parameters
string$encodingdefault: utf-8

Definition at line 96 of file UResponse.php.

◆ getResponseCode()

static getResponseCode ( )
static

Get the response code.

Returns
int

Definition at line 171 of file UResponse.php.

◆ header()

static header (   $headerField,
  $value,
  $replace = null,
  $responseCode = null 
)
static

Send a raw HTTP header.

Parameters
string$headerFieldthe header field
string$valuethe header value
boolean$replaceThe optional replace parameter indicates whether the header should replace a previous similar header
int$responseCodeForces the HTTP response code to the specified value

Definition at line 28 of file UResponse.php.

◆ isJSON()

static isJSON ( )
static

Definition at line 76 of file UResponse.php.

◆ isSent()

static isSent ( )
static

Checks if or where headers have been sent.

Returns
boolean

Definition at line 65 of file UResponse.php.

◆ noCache()

static noCache ( )
static

Forces the disabling of the browser cache.

Definition at line 55 of file UResponse.php.

◆ setAccept()

static setAccept (   $value)
static

Sets the Accept header.

Parameters
string$valueone of Http accept values
See also
https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation/List_of_default_Accept_values

Definition at line 117 of file UResponse.php.

◆ setAccessControlHeaders()

static setAccessControlHeaders (   $headers)
static

Sets the Access-Control-Allow-Headers field value.

Parameters
string | array$headers

Definition at line 144 of file UResponse.php.

◆ setAccessControlMethods()

static setAccessControlMethods (   $methods)
static

Sets the Access-Control-Allow-Methods field value.

Parameters
string | array$methods

Definition at line 135 of file UResponse.php.

◆ setAccessControlOrigin()

static setAccessControlOrigin (   $origin)
static

Sets the Access-Control-Allow-Origin field value.

Parameters
string$origin

Definition at line 126 of file UResponse.php.

◆ setAuthorization()

static setAuthorization (   $authorization)
static

Set the Authorization header field.

Parameters
string$authorization

Definition at line 153 of file UResponse.php.

◆ setContentType()

static setContentType (   $contentType,
  $encoding = null 
)
static

Definition at line 45 of file UResponse.php.

◆ setResponseCode()

static setResponseCode (   $value)
static

Sets the response code.

Parameters
int$value

Definition at line 162 of file UResponse.php.

Field Documentation

◆ $headers

$headers =[]
static

Definition at line 14 of file UResponse.php.


The documentation for this class was generated from the following file: