Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/check/PhabricatorWebServerSetupCheck.php
| Show All 39 Lines | protected function executeChecks() { | ||||
| $base_uri = id(new PhutilURI($base_uri)) | $base_uri = id(new PhutilURI($base_uri)) | ||||
| ->setPath($send_path) | ->setPath($send_path) | ||||
| ->replaceQueryParam($expect_key, $expect_value); | ->replaceQueryParam($expect_key, $expect_value); | ||||
| $self_future = id(new HTTPSFuture($base_uri)) | $self_future = id(new HTTPSFuture($base_uri)) | ||||
| ->addHeader('X-Phabricator-SelfCheck', 1) | ->addHeader('X-Phabricator-SelfCheck', 1) | ||||
| ->addHeader('Accept-Encoding', 'gzip') | ->addHeader('Accept-Encoding', 'gzip') | ||||
| ->setDisableContentDecoding(true) | |||||
| ->setHTTPBasicAuthCredentials( | ->setHTTPBasicAuthCredentials( | ||||
| $expect_user, | $expect_user, | ||||
| new PhutilOpaqueEnvelope($expect_pass)) | new PhutilOpaqueEnvelope($expect_pass)) | ||||
| ->setTimeout(5); | ->setTimeout(5); | ||||
| if (AphrontRequestStream::supportsGzip()) { | if (AphrontRequestStream::supportsGzip()) { | ||||
| $gzip_uncompressed = str_repeat('Quack! ', 128); | $gzip_uncompressed = str_repeat('Quack! ', 128); | ||||
| $gzip_compressed = gzencode($gzip_uncompressed); | $gzip_compressed = gzencode($gzip_uncompressed); | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | if (BaseHTTPFuture::getHeader($headers, 'Content-Encoding') != 'gzip') { | ||||
| 'for clients with less bandwidth.'); | 'for clients with less bandwidth.'); | ||||
| $this->newIssue('webserver.gzip') | $this->newIssue('webserver.gzip') | ||||
| ->setName(pht('GZip Compression May Not Be Enabled')) | ->setName(pht('GZip Compression May Not Be Enabled')) | ||||
| ->setSummary(pht('Your webserver may have compression disabled.')) | ->setSummary(pht('Your webserver may have compression disabled.')) | ||||
| ->setMessage($message); | ->setMessage($message); | ||||
| } else { | } else { | ||||
| if (function_exists('gzdecode')) { | if (function_exists('gzdecode')) { | ||||
| $body = gzdecode($body); | $body = @gzdecode($body); | ||||
| } else { | } else { | ||||
| $body = null; | $body = null; | ||||
| } | } | ||||
| if (!$body) { | if (!$body) { | ||||
| // For now, just bail if we can't decode the response. | // For now, just bail if we can't decode the response. | ||||
| // This might need to use the stronger magic in "AphrontRequestStream" | // This might need to use the stronger magic in "AphrontRequestStream" | ||||
| // to decode more reliably. | // to decode more reliably. | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | private function checkGzipResponse( | ||||
| try { | try { | ||||
| $structure = phutil_json_decode(trim($body)); | $structure = phutil_json_decode(trim($body)); | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| return; | return; | ||||
| } | } | ||||
| $raw_body = idx($structure, 'raw.base64'); | $raw_body = idx($structure, 'raw.base64'); | ||||
| $raw_body = base64_decode($raw_body); | $raw_body = @base64_decode($raw_body); | ||||
| // The server received the exact compressed bytes we expected it to, so | // The server received the exact compressed bytes we expected it to, so | ||||
| // everything is working great. | // everything is working great. | ||||
| if ($raw_body === $compressed) { | if ($raw_body === $compressed) { | ||||
| return; | return; | ||||
| } | } | ||||
| // If the server received a prefix of the raw uncompressed string, it | // If the server received a prefix of the raw uncompressed string, it | ||||
| ▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines | |||||