WordPress\AiClientDependencies\Nyholm\Psr7

ServerRequest::__constructpublicWP 1.0

Method of the class: ServerRequest{}

No Hooks.

Returns

null. Nothing (null).

Usage

$ServerRequest = new ServerRequest();
$ServerRequest->__construct( $method, $uri, $headers, $body, $version, $serverParams );
$method(string) (required)
HTTP method.
$uri(string|UriInterface) (required)
URI.
$headers(array)
Request headers.
Default: []
$body(string|resource|StreamInterface|null)
Request body.
Default: null
$version(string)
Protocol version.
Default: '1.1'
$serverParams(array)
Typically the $_SERVER superglobal.
Default: []

ServerRequest::__construct() code WP 7.0

public function __construct(string $method, $uri, array $headers = [], $body = null, string $version = '1.1', array $serverParams = [])
{
    $this->serverParams = $serverParams;
    if (!$uri instanceof UriInterface) {
        $uri = new Uri($uri);
    }
    $this->method = $method;
    $this->uri = $uri;
    $this->setHeaders($headers);
    $this->protocol = $version;
    \parse_str($uri->getQuery(), $this->queryParams);
    if (!$this->hasHeader('Host')) {
        $this->updateHostFromUri();
    }
    // If we got no body, defer initialization of the stream until ServerRequest::getBody()
    if ('' !== $body && null !== $body) {
        $this->stream = Stream::create($body);
    }
}