X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FResponse.php;h=d38b330bb3bd57fa1a6c337354d05041b50b18bc;hb=fd5914011cb5c67b827886a5db0e7760a307ad1d;hp=d24ebe954a8317aaa39a1fbf6a0cc1b8fb310a8f;hpb=6a9fff5100fa58e07a9812bb1836f3caca854379;p=friendica.git diff --git a/src/Module/Response.php b/src/Module/Response.php index d24ebe954a..d38b330bb3 100644 --- a/src/Module/Response.php +++ b/src/Module/Response.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Module; @@ -21,6 +40,10 @@ class Response implements ICanCreateResponses */ protected $type = self::TYPE_HTML; + protected $status = 200; + + protected $reason = null; + /** * {@inheritDoc} */ @@ -73,6 +96,9 @@ class Response implements ICanCreateResponses } switch ($type) { + case static::TYPE_HTML: + $content_type = $content_type ?? 'text/html; charset=utf-8'; + break; case static::TYPE_JSON: $content_type = $content_type ?? 'application/json'; break; @@ -92,6 +118,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} */ @@ -108,6 +143,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, '1.1', $this->reason); } }