Parameters
$statusintoptional- Status code
Default:
200 $headersarrayoptional- Response headers
Default:
[] $bodystring|resource|WordPressAiClientDependenciesPsrHttpMessageStreamInterface|nulloptional- Response body
Default:
null $versionstringoptional- Protocol version
Default:
'1.1' $reasonstring|nulloptional- Reason phrase (when empty a default will be used based on the status code)
Default:
null
Source
public function __construct(int $status = 200, array $headers = [], $body = null, string $version = '1.1', ?string $reason = null)
{
// If we got no body, defer initialization of the stream until Response::getBody()
if ('' !== $body && null !== $body) {
$this->stream = Stream::create($body);
}
$this->statusCode = $status;
$this->setHeaders($headers);
if (null === $reason && isset(self::PHRASES[$this->statusCode])) {
$this->reasonPhrase = self::PHRASES[$status];
} else {
$this->reasonPhrase = $reason ?? '';
}
$this->protocol = $version;
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.