Message
in package
implements
MessageInterface, Stringable
uses
StringableTrait
Phrity\WebSocket\Http\Message class.
Only used for handshake procedure.
Table of Contents
Interfaces
- MessageInterface
- HTTP messages consist of requests from a client to a server and responses from a server to a client. This interface defines the methods common to each.
- Stringable
Properties
Methods
- __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.
- 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.
- stringable() : string
- handleHeader() : void
Properties
$headers
protected
array<string|int, mixed>
$headers
= []
$version
protected
string
$version
= '1.1'
Methods
__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.
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
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