Stud.IP  6.0
Response Class Reference
Inheritance diagram for Response:
StudipResponse

Public Member Functions

 __construct (string $body='', array $headers=[], ?int $status=null, ?string $reason=null)
 
 set_body ($body)
 
 set_status ($status, $reason=null)
 
 add_header ($key, $value)
 
 output ()
 
 send_header ($header, $replace=false, $status=null)
 

Static Public Member Functions

static get_reason ($status)
 

Data Fields

 $body = ''
 
 $status
 
 $reason
 
 $headers = []
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( string  $body = '',
array  $headers = [],
?int  $status = null,
?string  $reason = null 
)

Constructor.

Parameters
string$bodythe body of the response defaulting to ''
array$headersan array of additional headers defaulting to an empty array
int | null$statusthe status code of the response defaulting to a regular 200
string | null$reasonthe descriptional reason for a status code defaulting to the standard reason phrases defined in RFC 2616

Member Function Documentation

◆ add_header()

add_header (   $key,
  $value 
)

Adds an additional header to the response.

Parameters
string$keythe left hand key part
string$valuethe right hand value part
Returns
static this response object. Useful for cascading method calls.

◆ get_reason()

static get_reason (   $status)
static

Returns the reason phrase of this response according to RFC2616.

Parameters
int$statusthe response's status
Returns
string the reason phrase for this response's status

◆ output()

output ( )

Outputs this response to the client using "echo" and "header".

Returns
void

◆ send_header()

send_header (   $header,
  $replace = false,
  $status = null 
)

Internally used function to actually send headers

Parameters
string$headerthe HTTP header
bool$replaceoptional; TRUE if previously sent header should be replaced - FALSE otherwise (default)
integer$statusoptional; the HTTP response code
Returns
void

◆ set_body()

set_body (   $body)

Sets the body of the response.

Parameters
string$bodythe body
Returns
static this response object. Useful for cascading method calls.

◆ set_status()

set_status (   $status,
  $reason = null 
)

Sets the status code and an optional custom reason. If none is given, the standard reason phrase as of RFC 2616 is used.

Parameters
integer$statusthe status code
string$reasonthe custom reason, defaulting to the one given in RFC 2616
Returns
static this response object. Useful for cascading method calls.

Field Documentation

◆ $body

$body = ''

◆ $headers

$headers = []

◆ $reason

$reason

◆ $status

$status

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