Esempio n. 1
0
 /**
  * @return \Nano\Controller\Redirect
  * @param string $location
  * @param int $status
  */
 public function to($location, $status = 302)
 {
     $this->response->addHeader('Location', $location);
     $this->response->setStatus($status);
     return $this;
 }
Esempio n. 2
0
 protected function setUp()
 {
     $this->response = new \Nano\Controller\Response\Test();
     $this->response->addHeader('X-Header', 'value');
 }
Esempio n. 3
0
 public function testCheckingHeadersExists()
 {
     self::assertFalse($this->response->hasHeader('name'));
     $this->response->addHeader('name', 'value');
     self::assertTrue($this->response->hasHeader('name'));
 }
Esempio n. 4
0
 /**
  * @return \Nano\Controller\Response
  * @param \Nano\Controller\Response $response
  */
 protected function updateResponse(\Nano\Controller\Response $response)
 {
     if (!\Nano::app()->config->exists('errors')) {
         return $response;
     }
     $errors = \Nano::app()->config->get('errors');
     if (!isset($errors->response)) {
         return $response;
     }
     $responseClass = $errors->response;
     if (!class_exists($responseClass)) {
         return $response;
     }
     $class = new \ReflectionClass($responseClass);
     if (!$class->implementsInterface('Nano\\Application\\ErrorHandler\\ResponseModifier')) {
         return $response;
     }
     if (!$class->isInstantiable()) {
         return $response;
     }
     $customResponse = $class->newInstance();
     /** @var \Nano\Application\ErrorHandler\ResponseModifier $customResponse */
     $response->addHeader('X-Modified', 'true');
     $customResponse->update($response);
     return $response;
 }