response = $response; // Slim adds Authorization header. It's not needed. $this->response = $this->response->withoutHeader('Authorization'); } public function setStatus(int $code, ?string $reason = null): Response { $this->response = $this->response->withStatus($code, $reason ?? ''); return $this; } public function setHeader(string $name, string $value): Response { $this->response = $this->response->withHeader($name, $value); return $this; } public function addHeader(string $name, string $value): Response { $this->response = $this->response->withAddedHeader($name, $value); return $this; } public function getHeader(string $name): ?string { if (!$this->response->hasHeader($name)) { return null; } return $this->response->getHeaderLine($name); } public function hasHeader(string $name): bool { return $this->response->hasHeader($name); } /** * @return string[] */ public function getHeaderAsArray(string $name): array { if (!$this->response->hasHeader($name)) { return []; } return $this->response->getHeader($name); } public function writeBody(string $string): Response { $this->response->getBody()->write($string); return $this; } public function setBody(StreamInterface $body): Response { $this->response = $this->response->withBody($body); return $this; } public function getResponse(): Psr7Response { return $this->response; } }