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

@ -10,7 +10,7 @@ class Options extends BaseModule
protected function options(array $request = [])
{
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
$this->response->setHeader('Allow', implode(',', Router::ALLOWED_METHODS));
$this->response->setHeader(($this->server['SERVER_PROTOCOL'] ?? 'HTTP/1.1') . ' 204 No Content');
$this->response->setHeader(implode(',', Router::ALLOWED_METHODS), 'Allow');
$this->response->setStatus(204);
}
}