\rex_socket_response

Class for rex_socket responses.

Summary

Methods
Properties
Constants
__construct()
getStatusCode()
getStatusMessage()
isOk()
isInformational()
isSuccessful()
isRedirection()
isClientError()
isServerError()
isInvalid()
getHeader()
getBufferedBody()
getBody()
writeBodyTo()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

__construct()

__construct(resource  $stream) : mixed

Constructor.

Parameters

resource $stream

Socket stream

Throws

\InvalidArgumentException

Returns

mixed —

getStatusCode()

getStatusCode() : int

Returns the HTTP status code, e.g. 200.

Returns

int —

getStatusMessage()

getStatusMessage() : string

Returns the HTTP status message, e.g. "OK".

Returns

string —

isOk()

isOk() : bool

Returns wether the status is "200 OK".

Returns

bool —

isInformational()

isInformational() : bool

Returns wether the status class is "Informational".

Returns

bool —

isSuccessful()

isSuccessful() : bool

Returns wether the status class is "Success".

Returns

bool —

isRedirection()

isRedirection() : bool

Returns wether the status class is "Redirection".

Returns

bool —

isClientError()

isClientError() : bool

Returns wether the status class is "Client Error".

Returns

bool —

isServerError()

isServerError() : bool

Returns wether the status class is "Server Error".

Returns

bool —

isInvalid()

isInvalid() : bool

Returns wether the status is invalid.

Returns

bool —

getHeader()

getHeader(string  $key = null, string  $default = null) : string|null

Returns the header for the given key, or the entire header if no key is given.

Parameters

string $key

Header key

string $default

Default value (is returned if the header is not set)

Returns

string|null —

getBufferedBody()

getBufferedBody(int  $length = 1024) : false|string

Returns up to `$length` bytes from the body, or `false` if the end is reached.

Parameters

int $length

Max number of bytes

Returns

false|string —

getBody()

getBody() : string

Returns the entire body.

Returns

string —

writeBodyTo()

writeBodyTo(string|resource  $resource) : bool

Writes the body to the given resource.

Parameters

string|resource $resource

File path or file pointer

Returns

bool —

true on success, false on failure