PHP Class Scalr\Api\Rest\Http\Response

Since: 5.4.0 (10.02.2015)
Author: Vitaliy Demidov ([email protected])
Afficher le fichier Open project: scalr/scalr Class Usage Examples

Protected Properties

Свойство Type Description
$messages

Méthodes publiques

Méthode Description
__construct ( string $body = '', integer $status = 200, array $headers = [] ) Constructor
addBody ( string $body ) : Response Add to body
addHeaders ( array $headers ) : Response Adds headers
finalize ( ) : array Prepares response to be sent
getBody ( ) : string Gets response body
getCodeMessage ( integer $code ) : string Gets the message for the specified HTTP code
getContentLength ( ) : number Gets content length
getContentType ( ) : string Gets content type as header Content-Type value
getHeader ( string $name ) : string Gets specified header
getHeaders ( ) : array Gets all headers
getStatus ( ) : number Gets response status code
redirect ( string $url, integer $status = 302 ) : Response Redirect
removeHeader ( string $name ) : Response Removes specified header
setBody ( string $body ) : Response Sets response body
setContentType ( string $type, string $encoding = "utf-8" ) Sets content MIME type and encoding
setHeader ( string $name, string $value ) : Response Sets header
setHeaders ( array $headers ) : Response Sets headers
setStatus ( integer $status ) : Response Sets status code

Method Details

__construct() public méthode

Constructor
public __construct ( string $body = '', integer $status = 200, array $headers = [] )
$body string The HTTP response body
$status integer The HTTP response status
$headers array The HTTP response headers

addBody() public méthode

Add to body
public addBody ( string $body ) : Response
$body string The body
Résultat Response

addHeaders() public méthode

Adds headers
public addHeaders ( array $headers ) : Response
$headers array The response headers
Résultat Response

finalize() public méthode

Prepares response to be sent
public finalize ( ) : array
Résultat array Returns array looks like array(status, headers, body)

getBody() public méthode

Gets response body
public getBody ( ) : string
Résultat string

getCodeMessage() public static méthode

Gets the message for the specified HTTP code
public static getCodeMessage ( integer $code ) : string
$code integer
Résultat string Returns the message for the specified HTTP code

getContentLength() public méthode

Gets content length
public getContentLength ( ) : number
Résultat number Returns content length

getContentType() public méthode

Gets content type as header Content-Type value
public getContentType ( ) : string
Résultat string

getHeader() public méthode

Gets specified header
public getHeader ( string $name ) : string
$name string The name of the HTTP Header
Résultat string Returns the value of the specified HTTP Header

getHeaders() public méthode

Gets all headers
public getHeaders ( ) : array
Résultat array Returns all HTTP headers as array

getStatus() public méthode

Gets response status code
public getStatus ( ) : number
Résultat number Returns status code

redirect() public méthode

Redirect
public redirect ( string $url, integer $status = 302 ) : Response
$url string The redirect url
$status integer optional The redirect HTTP status code
Résultat Response

removeHeader() public méthode

Removes specified header
public removeHeader ( string $name ) : Response
$name string A header name
Résultat Response

setBody() public méthode

Sets response body
public setBody ( string $body ) : Response
$body string The response body
Résultat Response

setContentType() public méthode

Sets content MIME type and encoding
public setContentType ( string $type, string $encoding = "utf-8" )
$type string Content MIME type
$encoding string optional Content encoding

setHeader() public méthode

Sets header
public setHeader ( string $name, string $value ) : Response
$name string A header name ('heaer-name')
$value string A value
Résultat Response

setHeaders() public méthode

Sets headers
public setHeaders ( array $headers ) : Response
$headers array The response headers looks like array('header-name' => value)
Résultat Response

setStatus() public méthode

Sets status code
public setStatus ( integer $status ) : Response
$status integer
Résultat Response

Property Details

$messages protected_oe static_oe property

protected static $messages