Ejemplo n.º 1
0
 /**
  * @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;
 }
Ejemplo n.º 2
0
 /**
  * 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>');
 }