/** * @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; }
protected function setUp() { $this->response = new \Nano\Controller\Response\Test(); $this->response->addHeader('X-Header', 'value'); }
public function testCheckingHeadersExists() { self::assertFalse($this->response->hasHeader('name')); $this->response->addHeader('name', 'value'); self::assertTrue($this->response->hasHeader('name')); }
/** * @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; }