X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FResponse.php;h=d24ebe954a8317aaa39a1fbf6a0cc1b8fb310a8f;hb=c18bda9397d0ea9d68ea7a81e6292459317fdbf5;hp=29df82c04432cf2f1398a9cac023a5bcf82f015d;hpb=ae24bf8d5403743dfb4f4400e436ddf97499825e;p=friendica.git diff --git a/src/Module/Response.php b/src/Module/Response.php index 29df82c044..d24ebe954a 100644 --- a/src/Module/Response.php +++ b/src/Module/Response.php @@ -19,7 +19,7 @@ class Response implements ICanCreateResponses /** * @var string */ - protected $type = ICanCreateResponses::TYPE_HTML; + protected $type = self::TYPE_HTML; /** * {@inheritDoc} @@ -68,7 +68,7 @@ class Response implements ICanCreateResponses */ public function setType(string $type, ?string $content_type = null): void { - if (!in_array($type, ICanCreateResponses::ALLOWED_TYPES)) { + if (!in_array($type, static::ALLOWED_TYPES)) { throw new InternalServerErrorException('wrong type'); } @@ -79,9 +79,14 @@ class Response implements ICanCreateResponses case static::TYPE_XML: $content_type = $content_type ?? 'text/xml'; break; + case static::TYPE_RSS: + $content_type = $content_type ?? 'application/rss+xml'; + break; + case static::TYPE_ATOM: + $content_type = $content_type ?? 'application/atom+xml'; + break; } - $this->setHeader($content_type, 'Content-type'); $this->type = $type; @@ -101,7 +106,7 @@ class Response implements ICanCreateResponses public function generate(): ResponseInterface { // Setting the response type as an X-header for direct usage - $this->headers['X-RESPONSE-TYPE'] = $this->type; + $this->headers[static::X_HEADER] = $this->type; return new \GuzzleHttp\Psr7\Response(200, $this->headers, $this->content); }