Changeset View
Changeset View
Standalone View
Standalone View
support/PhabricatorStartup.php
| Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | public static function setAccessLog($access_log) { | ||||
| self::$accessLog = $access_log; | self::$accessLog = $access_log; | ||||
| } | } | ||||
| /** | /** | ||||
| * @task info | * @task info | ||||
| */ | */ | ||||
| public static function getRawInput() { | 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; | return self::$rawInput; | ||||
| } | } | ||||
| /* -( Startup Hooks )------------------------------------------------------ */ | /* -( Startup Hooks )------------------------------------------------------ */ | ||||
| /** | /** | ||||
| Show All 29 Lines | public static function didStartup($start_time) { | ||||
| self::normalizeInput(); | self::normalizeInput(); | ||||
| self::verifyRewriteRules(); | self::verifyRewriteRules(); | ||||
| self::detectPostMaxSizeTriggered(); | self::detectPostMaxSizeTriggered(); | ||||
| self::beginOutputCapture(); | 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; | |||||
| } | } | ||||
| /** | /** | ||||
| * @task hook | * @task hook | ||||
| */ | */ | ||||
| public static function didShutdown() { | public static function didShutdown() { | ||||
| $event = error_get_last(); | $event = error_get_last(); | ||||
| ▲ Show 20 Lines • Show All 777 Lines • Show Last 20 Lines | |||||