mirror of
https://github.com/friendica/friendica
synced 2025-04-22 07:50:11 +00:00
Add explicit status setting for PSR/ResponseInterface & add tests for OPTIONS endpoint
This commit is contained in:
parent
3092e74a3a
commit
eaad220738
6 changed files with 60 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue