Exemple #1
0
 protected static function createHeaders(Sabel_Response $response)
 {
     $headers = array();
     $status = $response->getStatus();
     $httpVersion = "HTTP/" . $response->getHttpVersion();
     $headers[] = $httpVersion . " " . $status->toString();
     if ($response->hasHeaders()) {
         foreach ($response->getHeaders() as $message => $value) {
             $headers[] = ucfirst($message) . ": " . $value;
         }
     }
     if (in_array($status->getCode(), self::$redirectCode, true)) {
         $headers[] = "Location: " . $response->getLocation();
     }
     return $headers;
 }
Exemple #2
0
 /**
  * execute action
  *
  * @access public
  * @param string $action action method name
  * @return mixed result of execute an action.
  */
 public function execute($action = null, $params = array())
 {
     if ($action === null) {
         $action = $this->action;
     }
     if ($this->isReserved($action) || $this->isHiddenAction($action)) {
         $this->response->getStatus()->setCode(Sabel_Response::NOT_FOUND);
     } elseif ($this->isValidAction($action)) {
         if (count($params) >= 1) {
             call_user_func_array(array($this, $action), $params);
         } else {
             $this->{$action}();
         }
         $this->executed = true;
     }
     return $this;
 }