示例#1
0
 function test_ServerDefaultConfiguration()
 {
     $server = Oops_Server::newInstance();
     $this->assertNotEquals('', (string) $server->config->oops->default_action);
     $this->assertNotEquals('', (string) $server->config->oops->default_extension);
     $this->assertNotEquals('', (string) $server->config->router->class);
 }
示例#2
0
 /**
  * Handle the request
  *
  * @todo proceed 301, 302, 404 and other statuses. Current response object should be used for this, or Oops_Server::Run should return a response object instead of text
  *
  * @return void
  */
 function _handle()
 {
     if ($this->_isHandled) {
         return;
     }
     $server = Oops_Server::newInstance();
     $response = $server->Run($this->_request);
     while ($response->isRedirect() && $this->_redirectLimit--) {
         /**
          * @todo do something, use Location header
          */
         $this->_request = new Oops_Server_Request_Custom($response->getHeader("Location"));
         $response = $server->Run($this->_request);
     }
     Oops_Server::popInstance();
     $server = null;
     if (!$response->isRedirect()) {
         $this->_content = $response->body;
         /* translate headers in order to deliver control headers like 'X-Accel-Expires' */
         $childHeaders = $response->getHeaders();
         if (count($childHeaders)) {
             $parentHeaders = Oops_Server::getResponse()->getHeaders();
             foreach ($childHeaders as $k => $v) {
                 if (!isset($parentHeaders[$k])) {
                     Oops_Server::getResponse()->setHeader($k, $v);
                 } elseif (is_array($parentHeaders[$k])) {
                     Oops_Utils::ToArray($v);
                     foreach ($v as $vv) {
                         Oops_Server::getResponse()->setHeader($k, $vv, false);
                     }
                 }
             }
         }
     }
     $this->_isHandled = true;
     $this->_position = 0;
 }
示例#3
0
 /**
  * Initial server run using http request and processing http response
  * Uses default config location of application/config/oops.ini
  * Outputs the response
  *
  * @return void
  */
 public static function RunHttpDefault()
 {
     $server = Oops_Server::newInstance(new Oops_Config_Ini('./application/config/oops.ini'));
     $response = $server->Run();
     echo $response->toString();
 }