PHP Class Scalr\Api\Rest\Http\Response

Since: 5.4.0 (10.02.2015)
Author: Vitaliy Demidov ([email protected])
显示文件 Open project: scalr/scalr Class Usage Examples

Protected Properties

Property Type Description
$messages

Public Methods

Method 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 method

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 method

Add to body
public addBody ( string $body ) : Response
$body string The body
return Response

addHeaders() public method

Adds headers
public addHeaders ( array $headers ) : Response
$headers array The response headers
return Response

finalize() public method

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

getBody() public method

Gets response body
public getBody ( ) : string
return string

getCodeMessage() public static method

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

getContentLength() public method

Gets content length
public getContentLength ( ) : number
return number Returns content length

getContentType() public method

Gets content type as header Content-Type value
public getContentType ( ) : string
return string

getHeader() public method

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

getHeaders() public method

Gets all headers
public getHeaders ( ) : array
return array Returns all HTTP headers as array

getStatus() public method

Gets response status code
public getStatus ( ) : number
return number Returns status code

redirect() public method

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

removeHeader() public method

Removes specified header
public removeHeader ( string $name ) : Response
$name string A header name
return Response

setBody() public method

Sets response body
public setBody ( string $body ) : Response
$body string The response body
return Response

setContentType() public method

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 method

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

setHeaders() public method

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

setStatus() public method

Sets status code
public setStatus ( integer $status ) : Response
$status integer
return Response

Property Details

$messages protected_oe static_oe property

protected static $messages