Request
extends Message
in package
implements
RequestInterface
WebSocket\Http\Request class.
Only used for handshake procedure.
Table of Contents
Interfaces
- RequestInterface
- Representation of an outgoing, client-side request.
Properties
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.
- getMethod() : string
- Retrieves the HTTP method of the request.
- getProtocolVersion() : string
- Retrieves the HTTP protocol version as a string.
- getRequestTarget() : string
- Retrieves the message's request target.
- getUri() : UriInterface
- Retrieves the URI instance.
- 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.
- withMethod() : static
- Return an instance with the provided HTTP method.
- withoutHeader() : static
- Return an instance without the specified header.
- withProtocolVersion() : static
- Return an instance with the specified HTTP protocol version.
- withRequestTarget() : static
- Return an instance with the specific request-target.
- withUri() : static
- Returns an instance with the provided URI.
- stringable() : string
- formatHostHeader() : string
- handleHeader() : void
Properties
$headers
protected
array<string|int, mixed>
$headers
= []
$version
protected
string
$version
= '1.1'
$method
private
string
$method
$target
private
string
$target
= ''
$uri
private
Uri
$uri
Methods
__construct()
public
__construct([string $method = 'GET' ][, UriInterface|string|null $uri = null ]) : mixed
Parameters
- $method : string = 'GET'
- $uri : UriInterface|string|null = null
__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.
getMethod()
Retrieves the HTTP method of the request.
public
getMethod() : string
Return values
string —Returns the request method.
getProtocolVersion()
Retrieves the HTTP protocol version as a string.
public
getProtocolVersion() : string
Return values
string —HTTP protocol version.
getRequestTarget()
Retrieves the message's request target.
public
getRequestTarget() : string
Return values
stringgetUri()
Retrieves the URI instance.
public
getUri() : UriInterface
This method MUST return a UriInterface instance.
Return values
UriInterface —Returns a UriInterface instance representing the URI of the request.
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
staticwithMethod()
Return an instance with the provided HTTP method.
public
withMethod(string $method) : static
Parameters
- $method : string
-
Case-sensitive method.
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
staticwithRequestTarget()
Return an instance with the specific request-target.
public
withRequestTarget(mixed $requestTarget) : static
Parameters
- $requestTarget : mixed
Return values
staticwithUri()
Returns an instance with the provided URI.
public
withUri(UriInterface $uri[, bool $preserveHost = false ]) : static
Parameters
- $uri : UriInterface
-
New request URI to use.
- $preserveHost : bool = false
-
Preserve the original state of the Host header.
Return values
staticstringable()
protected
stringable(string $format, mixed ...$values) : string
Parameters
- $format : string
- $values : mixed
Return values
stringformatHostHeader()
private
formatHostHeader(Uri $uri) : string
Parameters
- $uri : Uri
Return values
stringhandleHeader()
private
handleHeader(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed