function setStatus(HttpStatus $status)
 {
     $protocol = $this->request ? $this->request->getProtocol() : 'HTTP/1.0';
     header($protocol . ' ' . $status->getValue() . ' ' . $status->getStatusMessage(), true);
 }
Esempio n. 2
0
 public function _sendResponse($status = 200, $body = '', $content_type = 'text/html')
 {
     $statusMessage = HttpStatus::getStatusMessage($status);
     // set the status
     $status_header = 'HTTP/1.1 ' . $status . ' ' . $statusMessage;
     header($status_header);
     header('Content-type: ' . $content_type);
     // pages with body are easy
     if ($body != '') {
         // send the body
         echo CJSON::encode($body);
         exit;
     } else {
         $data = array();
         $data['status'] = $status;
         $data['statusMessage'] = $statusMessage;
         // create some body messages
         $data['message'] = HttpStatus::getResponse($status);
         // servers don't always have a signature turned on
         // (this is an apache directive "ServerSignature On")
         $data['signature'] = $_SERVER['SERVER_SIGNATURE'] == '' ? $_SERVER['SERVER_SOFTWARE'] . ' Server at ' . $_SERVER['SERVER_NAME'] . ' Port ' . $_SERVER['SERVER_PORT'] : $_SERVER['SERVER_SIGNATURE'];
         $this->renderPartial('application.views.http._htmlResponse', array('data' => $data));
         exit;
     }
 }