Example #1
0
 /**
  * The actual processing of a request, this should look somewhat similar to request.c:ap_process_request_internal()
  *
  * @return int status
  */
 function processRequest()
 {
     $r = $this->_container->getRequest();
     $this->getLogger()->log(\HTRouter\Logger::ERRORLEVEL_DEBUG, "processRequest(" . $r->getUri() . ")");
     $utils = new \HTRouter\Utils();
     // If you are looking for proxy stuff. It's not here to simplify things
     // Remove /. /.. and // from the URI
     $realUri = $utils->getParents($r->getUri());
     $r->setUri($realUri);
     // We don't have a filename yet, try to find the file that corresponds to the URI we need
     $status = $this->_locationWalk($r);
     if ($status != \HTRouter::STATUS_OK) {
         return $status;
     }
     $status = $this->getRouter()->runHook(\HTRouter::HOOK_TRANSLATE_NAME, \HTRouter::RUNHOOK_FIRST, $this->_container);
     if ($status != \HTRouter::STATUS_OK) {
         return $this->_declDie($status, "translate", $r);
     }
     $status = $this->getRouter()->runHook(\HTRouter::HOOK_MAP_TO_STORAGE, \HTRouter::RUNHOOK_FIRST, $this->_container);
     if ($status != \HTRouter::STATUS_OK) {
         return $status;
     }
     if ($r->isMainRequest()) {
         $status = $this->getRouter()->runHook(\HTRouter::HOOK_HEADER_PARSER, \HTRouter::RUNHOOK_FIRST, $this->_container);
         if ($status != \HTRouter::STATUS_OK) {
             return $status;
         }
     }
     // We always re-authenticate. Something request.c doesn't do for optimizing. Easy enough to create though.
     $status = $this->_authenticate($r);
     if ($status != \HTRouter::STATUS_OK) {
         return $status;
     }
     $status = $this->getRouter()->runHook(\HTRouter::HOOK_CHECK_TYPE, \HTRouter::RUNHOOK_FIRST, $this->_container);
     if ($status != \HTRouter::STATUS_OK) {
         return $this->_declDie($status, "find types", $r);
     }
     $status = $this->getRouter()->runHook(\HTRouter::HOOK_FIXUPS, \HTRouter::RUNHOOK_ALL, $this->_container);
     if ($status != \HTRouter::STATUS_OK) {
         return $status;
     }
     // If everything is ok. Note that we return 200 OK instead of "OK" since we need to return a code for the
     // router to work with...
     return \HTRouter::STATUS_HTTP_OK;
 }