Add explicit status setting for PSR/ResponseInterface & add tests for OPTIONS endpoint

This commit is contained in:
Philipp 2022-01-02 21:28:28 +01:00
parent 3092e74a3a
commit eaad220738
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
6 changed files with 60 additions and 4 deletions

View file

@ -40,6 +40,10 @@ class Response implements ICanCreateResponses
*/
protected $type = self::TYPE_HTML;
protected $status = 200;
protected $reason = null;
/**
* {@inheritDoc}
*/
@ -111,6 +115,15 @@ class Response implements ICanCreateResponses
$this->type = $type;
}
/**
* {@inheritDoc}
*/
public function setStatus(int $status = 200, ?string $reason = null): void
{
$this->status = $status;
$this->reason = $reason;
}
/**
* {@inheritDoc}
*/
@ -127,6 +140,6 @@ class Response implements ICanCreateResponses
// Setting the response type as an X-header for direct usage
$this->headers[static::X_HEADER] = $this->type;
return new \GuzzleHttp\Psr7\Response(200, $this->headers, $this->content);
return new \GuzzleHttp\Psr7\Response($this->status, $this->headers, $this->content, $this->reason);
}
}