Response
extends Message
in package
implements
ResponseInterface
Phrity\WebSocket\Http\Response class.
Only used for handshake procedure.
Table of Contents
Interfaces
- ResponseInterface
- Representation of an outgoing, server-side response.
Properties
- $headers : array<string|int, mixed>
- $version : string
- $code : int
- $codes : array<string|int, mixed>
- $reason : string
Methods
- __construct() : mixed
- __toString() : string
- getAsArray() : array<string|int, mixed>
- getBody() : StreamInterface
- Not implemented, WebSocket only use headers.
- getHeader() : array<string|int, string>
- Retrieves a message header value by the given case-insensitive name.
- getHeaderLine() : string
- Retrieves a comma-separated string of the values for a single header.
- getHeaders() : array<string|int, array<string|int, string>>
- Retrieves all message header values.
- getProtocolVersion() : string
- Retrieves the HTTP protocol version as a string.
- getReasonPhrase() : string
- Gets the response reason phrase associated with the status code.
- getStatusCode() : int
- Gets the response status code.
- hasHeader() : bool
- Checks if a header exists by the given case-insensitive name.
- withAddedHeader() : static
- Return an instance with the specified header appended with the given value.
- withBody() : static
- Not implemented, WebSocket only use headers.
- withHeader() : static
- Return an instance with the provided value replacing the specified header.
- withoutHeader() : static
- Return an instance without the specified header.
- withProtocolVersion() : static
- Return an instance with the specified HTTP protocol version.
- withStatus() : static
- Return an instance with the specified status code and, optionally, reason phrase.
- stringable() : string
- handleHeader() : void
Properties
$headers
protected
array<string|int, mixed>
$headers
= []
$version
protected
string
$version
= '1.1'
$code
private
int
$code
$codes
private
static array<string|int, mixed>
$codes
= [100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 103 => 'Early Hints', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', 208 => 'Already Reported', 226 => 'IM Used', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Content Too Large', 414 => 'URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Range Not Satisfiable', 417 => 'Expectation Failed', 421 => 'Misdirected Request', 422 => 'Unprocessable Content', 423 => 'Locked', 424 => 'Failed Dependency', 425 => 'Too Early', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 451 => 'Unavailable For Legal Reasons', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', 510 => 'Not Extended', 511 => 'Network Authentication Required']
$reason
private
string
$reason
Methods
__construct()
public
__construct([int $code = 200 ][, string $reasonPhrase = '' ]) : mixed
Parameters
- $code : int = 200
- $reasonPhrase : string = ''
__toString()
public
__toString() : string
Return values
stringgetAsArray()
public
getAsArray() : array<string|int, mixed>
Return values
array<string|int, mixed>getBody()
Not implemented, WebSocket only use headers.
public
getBody() : StreamInterface
Return values
StreamInterface —Returns the body as a stream.
getHeader()
Retrieves a message header value by the given case-insensitive name.
public
getHeader(string $name) : array<string|int, string>
Parameters
- $name : string
-
Case-insensitive header field name.
Return values
array<string|int, string> —An array of string values as provided for the given header.
getHeaderLine()
Retrieves a comma-separated string of the values for a single header.
public
getHeaderLine(string $name) : string
Parameters
- $name : string
-
Case-insensitive header field name.
Return values
string —A string of values as provided for the given header.
getHeaders()
Retrieves all message header values.
public
getHeaders() : array<string|int, array<string|int, string>>
Return values
array<string|int, array<string|int, string>> —Returns an associative array of the message's headers.
getProtocolVersion()
Retrieves the HTTP protocol version as a string.
public
getProtocolVersion() : string
Return values
string —HTTP protocol version.
getReasonPhrase()
Gets the response reason phrase associated with the status code.
public
getReasonPhrase() : string
Return values
string —Reason phrase; must return an empty string if none present.
getStatusCode()
Gets the response status code.
public
getStatusCode() : int
Return values
int —Status code.
hasHeader()
Checks if a header exists by the given case-insensitive name.
public
hasHeader(string $name) : bool
Parameters
- $name : string
-
Case-insensitive header field name.
Return values
bool —Returns true if any header names match the given header.
withAddedHeader()
Return an instance with the specified header appended with the given value.
public
withAddedHeader(string $name, string|array<string|int, string> $value) : static
Parameters
- $name : string
-
Case-insensitive header field name to add.
- $value : string|array<string|int, string>
-
Header value(s).
Tags
Return values
staticwithBody()
Not implemented, WebSocket only use headers.
public
withBody(StreamInterface $body) : static
Parameters
- $body : StreamInterface
-
Body.
Return values
staticwithHeader()
Return an instance with the provided value replacing the specified header.
public
withHeader(string $name, string|array<string|int, string> $value) : static
Parameters
- $name : string
-
Case-insensitive header field name.
- $value : string|array<string|int, string>
-
Header value(s).
Tags
Return values
staticwithoutHeader()
Return an instance without the specified header.
public
withoutHeader(string $name) : static
Parameters
- $name : string
-
Case-insensitive header field name to remove.
Return values
staticwithProtocolVersion()
Return an instance with the specified HTTP protocol version.
public
withProtocolVersion(string $version) : static
Parameters
- $version : string
-
HTTP protocol version
Return values
staticwithStatus()
Return an instance with the specified status code and, optionally, reason phrase.
public
withStatus(int $code[, string $reasonPhrase = '' ]) : static
Parameters
- $code : int
-
The 3-digit integer result code to set.
- $reasonPhrase : string = ''
-
The reason phrase to use.
Tags
Return values
staticstringable()
protected
stringable(string $format, mixed ...$values) : string
Parameters
- $format : string
- $values : mixed
Return values
stringhandleHeader()
private
handleHeader(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed