Properties

$file

$file : array

Send file info

Type

array

$_header

$_header : array

Header data.

Type

array

$_status

$_status : int

Http status.

Type

int

$_reason

$_reason : string

Http reason.

Type

string

$_version

$_version : string

Http version.

Type

string

$_body

$_body : string

Http body.

Type

string

$_mimeTypeMap

$_mimeTypeMap : array

Mine type map.

Type

array

$_phrases

$_phrases : array

Phrases.

Type

array

Methods

init()

init() : void

Init.

__construct()

__construct(int  $status = 200, array  $headers = array(), string  $body = '') : mixed

Response constructor.

Parameters

int $status
array $headers
string $body

Returns

mixed —

header()

header(string  $name, string  $value) : $this

Set header.

Parameters

string $name
string $value

Returns

$this —

withHeader()

withHeader(string  $name, string  $value) : \Workerman\Protocols\Http\Response

Set header.

Parameters

string $name
string $value

Returns

\Workerman\Protocols\Http\Response —

withHeaders()

withHeaders(array  $headers) : $this

Set headers.

Parameters

array $headers

Returns

$this —

withoutHeader()

withoutHeader(string  $name) : $this

Remove header.

Parameters

string $name

Returns

$this —

getHeader()

getHeader(string  $name) : null|array|string

Get header.

Parameters

string $name

Returns

null|array|string —

getHeaders()

getHeaders() : array

Get headers.

Returns

array —

withStatus()

withStatus(int  $code, string|null  $reason_phrase = null) : $this

Set status.

Parameters

int $code
string|null $reason_phrase

Returns

$this —

getStatusCode()

getStatusCode() : int

Get status code.

Returns

int —

getReasonPhrase()

getReasonPhrase() : string

Get reason phrase.

Returns

string —

withProtocolVersion()

withProtocolVersion(int  $version) : $this

Set protocol version.

Parameters

int $version

Returns

$this —

withBody()

withBody(string  $body) : $this

Set http body.

Parameters

string $body

Returns

$this —

rawBody()

rawBody() : string

Get http raw body.

Returns

string —

withFile()

withFile(string  $file, int  $offset, int  $length) : $this

Send file.

Parameters

string $file
int $offset
int $length

Returns

$this —

cookie()

cookie( $name, string  $value = '', int  $max_age, string  $path = '', string  $domain = '', bool  $secure = false, bool  $http_only = false, bool  $same_site = false) : $this

Set cookie.

Parameters

$name
string $value
int $max_age
string $path
string $domain
bool $secure
bool $http_only
bool $same_site

Returns

$this —

__toString()

__toString() : string

__toString.

Returns

string —

initMimeTypeMap()

initMimeTypeMap() : void

Init mime map.

createHeadForFile()

createHeadForFile(array  $file_info) : string

Create header for file.

Parameters

array $file_info

Returns

string —