Пример #1
0
 protected static function send_php_response()
 {
     ob_end_clean();
     # 丢弃开发者无意间 echo 出的内容
     visitor::persist_roles();
     $response = visitor::get_response();
     $status = $response['status'];
     if ($status['code'] !== 0) {
         header('HTTP/1.1 ' . $status['code'] . ' ' . $status['phrase']);
     }
     foreach ($response['headers'] as $key => $value) {
         header($key . ': ' . $value);
     }
     foreach ($response['cookies'] as $c) {
         setcookie($c['name'], $c['value'], $c['expire'], $c['path'], $c['domain'], $c['secure'], $c['http_only']);
     }
     $content_type = $response['content_type'];
     self::send_response(false, $content_type, $response['content'], $content_type === 'text/html; charset=utf-8');
 }