コード例 #1
0
ファイル: HttpResponse.php プロジェクト: Clansuite/Clansuite
 /**
  * This flushes the headers and bodydata to the client.
  */
 public static function sendResponse()
 {
     // save session before exit
     if ((bool) session_id()) {
         session_write_close();
     }
     // activateOutputCompression when not in debugging mode
     if (XDEBUG === false and DEBUG === false) {
         Koch_ResponseEncode::start_outputbuffering('7');
     }
     // Send the status line
     self::addHeader('HTTP/1.1', self::$statusCode . ' ' . self::getStatusCodeDescription(self::$statusCode));
     // Set X-Powered-By Header to Clansuite Signature
     self::addHeader('X-Powered-By', '[ Clansuite - just an eSport CMS ][ Version : ' . CLANSUITE_VERSION . ' ][ http://clansuite.com ]');
     // Suppress Framesets
     self::addHeader('X-Frame-Options', 'deny');
     // not SAMEORIGIN
     // Send our Content-Type with UTF-8 encoding
     self::addHeader('Content-Type', self::getContentType() . '; charset=UTF-8');
     // Send user specificed headers from self::$headers array
     if (false === headers_sent()) {
         foreach (self::$headers as $name => $value) {
             $header = $name . ': ' . $value;
             $header = str_replace(array("\n", "\r"), '', $header);
             // header injection
             header($header, false);
         }
     }
     // make it possible to attach HTML content to the body directly before flushing the response
     \Clansuite\CMS::triggerEvent('onBeforeResponse', array('content' => self::$content));
     // Finally echo the response body
     echo self::getContent();
     // Flush Compressed Buffer
     if (XDEBUG === false and DEBUG === false) {
         \Koch\Mvc\ResponseEncode::end_outputbuffering();
         // send response and do some more php processing afterwards
         if (is_callable('fastcgi_finish_request') === true) {
             fastcgi_finish_request();
         }
     }
     // OK, Reset -> Package delivered! Return to Base!
     self::clearHeaders();
 }