Parameters
$methodstringrequired- HTTP method
$uristring|WordPressAiClientDependenciesPsrHttpMessageUriInterfacerequired- URI
$headersarrayoptional- Request headers
Default:
[] $bodystring|resource|WordPressAiClientDependenciesPsrHttpMessageStreamInterface|nulloptional- Request body
Default:
null $versionstringoptional- Protocol version
Default:
'1.1' $serverParamsarrayoptional- Typically the $_SERVER superglobal
Default:
[]
Source
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);
}
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.