Exemplo n.º 1
0
 function test_Headers()
 {
     $response = new Oops_Server_Response();
     $response->setHeader('key', 'value');
     $this->assertEquals('value', $response->getHeader('key'), 'getHeader(key) mismatch');
     $this->assertEquals(array('key' => 'value'), $response->getHeaders());
     $this->assertEquals("Key: value\n", $response->getHeadersAsString(false), 'headers as string do not match standards: ' . $response->getHeadersAsString(false));
     $response->setCode(403, true);
     $this->assertEquals("HTTP/1.x 403 Forbidden\nKey: value\n", $response->getHeadersAsString(), "response->getHeadersAsString with status line");
 }
Exemplo n.º 2
0
 /**
  *
  * @todo Set error response code if there's no controller class found
  *      
  *       Controller instantiation. Uses $this->_controller as a class name
  *       (detected in DetectController), or starts default controller
  *       Oops_Controller
  */
 function _initController()
 {
     $ctrl = $this->_router->controller;
     if (!Oops_Loader::find($ctrl)) {
         trigger_error("Controller {$ctrl} not found", E_USER_ERROR);
         $this->_response->setHeader("Oops-Error", "Controller {$ctrl} not found");
         $this->_response->setCode(500);
         return;
     }
     $this->_controller_instance = new $ctrl();
 }