Documentation

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

$headers  : array<string|int, mixed>
$version  : string
$method  : string
$target  : string
$uri  : Uri

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'

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
string

getAsArray()

public getAsArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

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
string

getUri()

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
throws
InvalidArgumentException

for invalid header names.

throws
InvalidArgumentException

for invalid header values.

Return values
static

withHeader()

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
throws
InvalidArgumentException

for invalid header names or values.

Return values
static

withMethod()

Return an instance with the provided HTTP method.

public withMethod(string $method) : static
Parameters
$method : string

Case-sensitive method.

Tags
throws
InvalidArgumentException

for invalid HTTP methods.

Return values
static

withoutHeader()

Return an instance without the specified header.

public withoutHeader(string $name) : static
Parameters
$name : string

Case-insensitive header field name to remove.

Return values
static

withProtocolVersion()

Return an instance with the specified HTTP protocol version.

public withProtocolVersion(string $version) : static
Parameters
$version : string

HTTP protocol version

Return values
static

withRequestTarget()

Return an instance with the specific request-target.

public withRequestTarget(mixed $requestTarget) : static
Parameters
$requestTarget : mixed
Return values
static

withUri()

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
static

stringable()

protected stringable(string $format, mixed ...$values) : string
Parameters
$format : string
$values : mixed
Return values
string

formatHostHeader()

private formatHostHeader(Uri $uri) : string
Parameters
$uri : Uri
Return values
string

handleHeader()

private handleHeader(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed

        
On this page

Search results