Exemplo n.º 1
0
 /**
  * @task info
  */
 public static function getRawInput()
 {
     if (self::$rawInput === null) {
         $stream = new AphrontRequestStream();
         if (isset($_SERVER['HTTP_CONTENT_ENCODING'])) {
             $encoding = trim($_SERVER['HTTP_CONTENT_ENCODING']);
             $stream->setEncoding($encoding);
         }
         $input = '';
         do {
             $bytes = $stream->readData();
             if ($bytes === null) {
                 break;
             }
             $input .= $bytes;
         } while (true);
         self::$rawInput = $input;
     }
     return self::$rawInput;
 }
Exemplo n.º 2
0
 /**
  * @task hook
  */
 public static function didStartup()
 {
     self::$startTime = microtime(true);
     self::$globals = array();
     static $registered;
     if (!$registered) {
         // NOTE: This protects us against multiple calls to didStartup() in the
         // same request, but also against repeated requests to the same
         // interpreter state, which we may implement in the future.
         register_shutdown_function(array(__CLASS__, 'didShutdown'));
         $registered = true;
     }
     self::setupPHP();
     self::verifyPHP();
     if (isset($_SERVER['REMOTE_ADDR'])) {
         self::rateLimitRequest($_SERVER['REMOTE_ADDR']);
     }
     self::normalizeInput();
     self::verifyRewriteRules();
     self::detectPostMaxSizeTriggered();
     self::beginOutputCapture();
     self::$rawInput = (string) file_get_contents('php://input');
 }
 /**
  * @param float Request start time, from `microtime(true)`.
  * @task hook
  */
 public static function didStartup($start_time)
 {
     self::$startTime = $start_time;
     self::$phases = array();
     self::$accessLog = null;
     static $registered;
     if (!$registered) {
         // NOTE: This protects us against multiple calls to didStartup() in the
         // same request, but also against repeated requests to the same
         // interpreter state, which we may implement in the future.
         register_shutdown_function(array(__CLASS__, 'didShutdown'));
         $registered = true;
     }
     self::setupPHP();
     self::verifyPHP();
     // If we've made it this far, the environment isn't completely broken so
     // we can switch over to relying on our own exception recovery mechanisms.
     ini_set('display_errors', 0);
     if (isset($_SERVER['REMOTE_ADDR'])) {
         self::rateLimitRequest($_SERVER['REMOTE_ADDR']);
     }
     self::normalizeInput();
     self::verifyRewriteRules();
     self::detectPostMaxSizeTriggered();
     self::beginOutputCapture();
     self::$rawInput = (string) file_get_contents('php://input');
 }
Exemplo n.º 4
0
 /**
  * @param float Request start time, from `microtime(true)`.
  * @task hook
  */
 public static function didStartup($start_time)
 {
     self::$startTime = $start_time;
     self::$phases = array();
     self::$accessLog = null;
     static $registered;
     if (!$registered) {
         // NOTE: This protects us against multiple calls to didStartup() in the
         // same request, but also against repeated requests to the same
         // interpreter state, which we may implement in the future.
         register_shutdown_function(array(__CLASS__, 'didShutdown'));
         $registered = true;
     }
     self::setupPHP();
     self::verifyPHP();
     // If we've made it this far, the environment isn't completely broken so
     // we can switch over to relying on our own exception recovery mechanisms.
     ini_set('display_errors', 0);
     if (isset($_SERVER['REMOTE_ADDR'])) {
         self::rateLimitRequest($_SERVER['REMOTE_ADDR']);
     }
     self::normalizeInput();
     self::verifyRewriteRules();
     self::detectPostMaxSizeTriggered();
     self::beginOutputCapture();
     if (isset($_SERVER['HTTP_CONTENT_ENCODING'])) {
         $encoding = trim($_SERVER['HTTP_CONTENT_ENCODING']);
     } else {
         $encoding = null;
     }
     $input_stream = fopen('php://input', 'rb');
     if (!$input_stream) {
         self::didFatal('Unable to open "php://input" to read HTTP request body.');
     }
     if ($encoding === 'gzip') {
         $ok = stream_filter_append($input_stream, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 30));
         if (!$ok) {
             self::didFatal('Failed to append gzip inflate filter to HTTP request body input ' . 'stream.');
         }
     }
     $input_data = '';
     while (!feof($input_stream)) {
         $read_bytes = fread($input_stream, 16 * 1024);
         if ($read_bytes === false) {
             self::didFatal('Failed to read input bytes from HTTP request body.');
         }
         $input_data .= $read_bytes;
     }
     fclose($input_stream);
     self::$rawInput = $input_data;
 }