Documentation

ServerRequest extends Request
in package
implements ServerRequestInterface

WebSocket\Http\ServerRequest class.

Only used for handshake procedure.

Table of Contents

Interfaces

ServerRequestInterface
Representation of an incoming, server-side HTTP 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>
getAttribute()  : mixed
Retrieve a single derived request attribute.
getAttributes()  : array<string|int, mixed>
Retrieve attributes derived from the request.
getBody()  : StreamInterface
Not implemented, WebSocket only use headers.
getCookieParams()  : array<string|int, mixed>
Retrieves cookies sent by the client to the server.
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.
getParsedBody()  : null|array<string|int, mixed>|object
Retrieve any parameters provided in the request body.
getProtocolVersion()  : string
Retrieves the HTTP protocol version as a string.
getQueryParams()  : array<string|int, mixed>
Retrieves the deserialized query string arguments, if any.
getRequestTarget()  : string
Retrieves the message's request target.
getServerParams()  : array<string|int, mixed>
Retrieve server parameters.
getUploadedFiles()  : array<string|int, mixed>
Retrieve normalized file upload data.
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.
withAttribute()  : static
Return an instance with the specified derived request attribute.
withBody()  : static
Not implemented, WebSocket only use headers.
withCookieParams()  : static
Return an instance with the specified cookies.
withHeader()  : static
Return an instance with the provided value replacing the specified header.
withMethod()  : static
Return an instance with the provided HTTP method.
withoutAttribute()  : static
Return an instance that removes the specified derived request attribute.
withoutHeader()  : static
Return an instance without the specified header.
withParsedBody()  : static
Return an instance with the specified body parameters.
withProtocolVersion()  : static
Return an instance with the specified HTTP protocol version.
withQueryParams()  : static
Return an instance with the specified query string arguments.
withRequestTarget()  : static
Return an instance with the specific request-target.
withUploadedFiles()  : static
Create a new instance with the specified uploaded files.
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>

getAttribute()

Retrieve a single derived request attribute.

public getAttribute(string $name[, mixed $default = null ]) : mixed
Parameters
$name : string

The attribute name.

$default : mixed = null

Default value to return if the attribute does not exist.

getAttributes()

Retrieve attributes derived from the request.

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

Attributes derived from the request.

getCookieParams()

Retrieves cookies sent by the client to the server.

public getCookieParams() : 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.

getParsedBody()

Retrieve any parameters provided in the request body.

public getParsedBody() : null|array<string|int, mixed>|object
Return values
null|array<string|int, mixed>|object —

The deserialized body parameters, if any.

getProtocolVersion()

Retrieves the HTTP protocol version as a string.

public getProtocolVersion() : string
Return values
string —

HTTP protocol version.

getQueryParams()

Retrieves the deserialized query string arguments, if any.

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

getRequestTarget()

Retrieves the message's request target.

public getRequestTarget() : string
Return values
string

getServerParams()

Retrieve server parameters.

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

getUploadedFiles()

Retrieve normalized file upload data.

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

An array tree of UploadedFileInterface instances.

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

withAttribute()

Return an instance with the specified derived request attribute.

public withAttribute(string $name, mixed $value) : static
Parameters
$name : string

The attribute name.

$value : mixed

The value of the attribute.

Return values
static

withCookieParams()

Return an instance with the specified cookies.

public withCookieParams(array<string|int, mixed> $cookies) : static
Parameters
$cookies : array<string|int, mixed>

Array of key/value pairs representing cookies.

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

withoutAttribute()

Return an instance that removes the specified derived request attribute.

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

The attribute name.

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

withParsedBody()

Return an instance with the specified body parameters.

public withParsedBody(null|array<string|int, mixed>|object $data) : static
Parameters
$data : null|array<string|int, mixed>|object

The deserialized body data.

Tags
throws
InvalidArgumentException

if an unsupported argument type is provided.

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

withQueryParams()

Return an instance with the specified query string arguments.

public withQueryParams(array<string|int, mixed> $query) : static
Parameters
$query : array<string|int, mixed>

Array of query string arguments

Return values
static

withRequestTarget()

Return an instance with the specific request-target.

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

withUploadedFiles()

Create a new instance with the specified uploaded files.

public withUploadedFiles(array<string|int, mixed> $uploadedFiles) : static
Parameters
$uploadedFiles : array<string|int, mixed>

An array tree of UploadedFileInterface instances.

Tags
throws
InvalidArgumentException

if an invalid structure is provided.

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