Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/check/PhabricatorWebServerSetupCheck.php
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | if (BaseHTTPFuture::getHeader($headers, 'Content-Encoding') != 'gzip') { | ||||
// 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; | ||||
} | } | ||||
} | } | ||||
$structure = null; | $structure = null; | ||||
$caught = null; | |||||
$extra_whitespace = ($body !== trim($body)); | $extra_whitespace = ($body !== trim($body)); | ||||
if (!$extra_whitespace) { | |||||
try { | try { | ||||
$structure = phutil_json_decode($body); | $structure = phutil_json_decode(trim($body)); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$caught = $ex; | // Ignore the exception, we only care if the decode worked or not. | ||||
} | |||||
} | } | ||||
if (!$structure || $extra_whitespace) { | |||||
if (!$structure) { | if (!$structure) { | ||||
if ($extra_whitespace) { | |||||
$message = pht( | |||||
'Phabricator sent itself a test request and expected to get a bare '. | |||||
'JSON response back, but the response had extra whitespace at '. | |||||
'the beginning or end.'. | |||||
"\n\n". | |||||
'This usually means you have edited a file and left whitespace '. | |||||
'characters before the opening %s tag, or after a closing %s tag. '. | |||||
'Remove any leading whitespace, and prefer to omit closing tags.', | |||||
phutil_tag('tt', array(), '<?php'), | |||||
phutil_tag('tt', array(), '?>')); | |||||
} else { | |||||
$short = id(new PhutilUTF8StringTruncator()) | $short = id(new PhutilUTF8StringTruncator()) | ||||
->setMaximumGlyphs(1024) | ->setMaximumGlyphs(1024) | ||||
->truncateString($body); | ->truncateString($body); | ||||
$message = pht( | $message = pht( | ||||
'Phabricator sent itself a test request with the '. | 'Phabricator sent itself a test request with the '. | ||||
'"X-Phabricator-SelfCheck" header and expected to get a valid JSON '. | '"X-Phabricator-SelfCheck" header and expected to get a valid JSON '. | ||||
'response back. Instead, the response begins:'. | 'response back. Instead, the response begins:'. | ||||
"\n\n". | "\n\n". | ||||
'%s'. | '%s'. | ||||
"\n\n". | "\n\n". | ||||
'Something is misconfigured or otherwise mangling responses.', | 'Something is misconfigured or otherwise mangling responses.', | ||||
phutil_tag('pre', array(), $short)); | phutil_tag('pre', array(), $short)); | ||||
} else { | |||||
$message = pht( | |||||
'Phabricator sent itself a test request and expected to get a bare '. | |||||
'JSON response back. It received a JSON response, but the response '. | |||||
'had extra whitespace at the beginning or end.'. | |||||
"\n\n". | |||||
'This usually means you have edited a file and left whitespace '. | |||||
'characters before the opening %s tag, or after a closing %s tag. '. | |||||
'Remove any leading whitespace, and prefer to omit closing tags.', | |||||
phutil_tag('tt', array(), '<?php'), | |||||
phutil_tag('tt', array(), '?>')); | |||||
} | } | ||||
$this->newIssue('webserver.mangle') | $this->newIssue('webserver.mangle') | ||||
->setName(pht('Mangled Webserver Response')) | ->setName(pht('Mangled Webserver Response')) | ||||
->setSummary(pht('Your webserver produced an unexpected response.')) | ->setSummary(pht('Your webserver produced an unexpected response.')) | ||||
->setMessage($message); | ->setMessage($message); | ||||
// We can't run the other checks if we could not decode the response. | // We can't run the other checks if we could not decode the response. | ||||
if (!$structure) { | |||||
return; | return; | ||||
} | } | ||||
} | |||||
$actual_user = idx($structure, 'user'); | $actual_user = idx($structure, 'user'); | ||||
$actual_pass = idx($structure, 'pass'); | $actual_pass = idx($structure, 'pass'); | ||||
if (($expect_user != $actual_user) || ($actual_pass != $expect_pass)) { | if (($expect_user != $actual_user) || ($actual_pass != $expect_pass)) { | ||||
$message = pht( | $message = pht( | ||||
'Phabricator sent itself a test request with an "Authorization" HTTP '. | 'Phabricator sent itself a test request with an "Authorization" HTTP '. | ||||
'header, and expected those credentials to be transmitted. However, '. | 'header, and expected those credentials to be transmitted. However, '. | ||||
'they were absent or incorrect when received. Phabricator sent '. | 'they were absent or incorrect when received. Phabricator sent '. | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |