Esempio n. 1
0
     $response = $application->willSendResponse($response, $controller);
     $response->setRequest($request);
     $response_string = $response->buildResponseString();
 } catch (Exception $ex) {
     $write_guard->dispose();
     if ($access_log) {
         $access_log->write();
     }
     if ($original_exception) {
         $ex = new PhutilAggregateException("Multiple exceptions during processing and rendering.", array($original_exception, $ex));
     }
     phabricator_fatal('[Rendering Exception] ' . $ex->getMessage());
 }
 $write_guard->dispose();
 // TODO: Share the $sink->writeResponse() pathway here?
 $sink = new AphrontPHPHTTPSink();
 $sink->writeHTTPStatus($response->getHTTPResponseCode());
 $headers = $response->getCacheHeaders();
 $headers = array_merge($headers, $response->getHeaders());
 $sink->writeHeaders($headers);
 $sink->writeData($response_string);
 if ($access_log) {
     $access_log->setData(array('c' => $response->getHTTPResponseCode(), 'T' => (int) (1000000 * (microtime(true) - $__start__))));
     $access_log->write();
 }
 if (DarkConsoleXHProfPluginAPI::isProfilerRequested()) {
     $profile = DarkConsoleXHProfPluginAPI::stopProfiler();
     $profile_sample = id(new PhabricatorXHProfSample())->setFilePHID($profile);
     if (empty($_REQUEST['__profile__'])) {
         $sample_rate = PhabricatorEnv::getEnvConfig('debug.profile-rate');
     } else {
Esempio n. 2
0
    require_once $preamble_path;
}
PhabricatorStartup::didStartup();
$show_unexpected_traces = false;
try {
    PhabricatorStartup::loadCoreLibraries();
    PhabricatorEnv::initializeWebEnvironment();
    $show_unexpected_traces = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');
    // This is the earliest we can get away with this, we need env config first.
    PhabricatorAccessLog::init();
    $access_log = PhabricatorAccessLog::getLog();
    PhabricatorStartup::setGlobal('log.access', $access_log);
    $access_log->setData(array('R' => AphrontRequest::getHTTPHeader('Referer', '-'), 'r' => idx($_SERVER, 'REMOTE_ADDR', '-'), 'M' => idx($_SERVER, 'REQUEST_METHOD', '-')));
    DarkConsoleXHProfPluginAPI::hookProfiler();
    DarkConsoleErrorLogPluginAPI::registerErrorHandler();
    $sink = new AphrontPHPHTTPSink();
    $response = PhabricatorSetupCheck::willProcessRequest();
    if ($response) {
        PhabricatorStartup::endOutputCapture();
        $sink->writeResponse($response);
        return;
    }
    $host = AphrontRequest::getHTTPHeader('Host');
    $path = $_REQUEST['__path__'];
    switch ($host) {
        default:
            $config_key = 'aphront.default-application-configuration-class';
            $application = PhabricatorEnv::newObjectFromConfig($config_key);
            break;
    }
    $application->setHost($host);