/** * @param ResponseInterface $response * @return $this */ protected function applyHttpHeaders(ResponseInterface $response) { if (!empty($this->httpResponseCode)) { $response->setHttpResponseCode($this->httpResponseCode); } if ($this->statusHeaderCode) { $response->setStatusHeader($this->statusHeaderCode, $this->statusHeaderVersion, $this->statusHeaderPhrase); } if (!empty($this->headers)) { foreach ($this->headers as $headerData) { $response->setHeader($headerData['name'], $headerData['value'], $headerData['replace']); } } return $this; }
/** * Set "auth failed" headers to the specified response object * * @param string $realm * @return void */ public function setAuthenticationFailed($realm) { $this->response->setStatusHeader(401, '1.1', 'Unauthorized'); $this->response->setHeader('WWW-Authenticate', 'Basic realm="' . $realm . '"')->setBody('<h1>401 Unauthorized</h1>'); }