1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Somewhat proper 404 page, plus HTTP response code.

This commit is contained in:
epriestley 2011-01-30 08:44:28 -08:00
parent 9f04548ab9
commit 6c37f918b1
5 changed files with 40 additions and 1 deletions

View file

@ -150,13 +150,22 @@ class AphrontDefaultApplicationConfiguration
$response->setContent($view->render());
return $response;
}
} else if ($response instanceof Aphront404Response) {
$view = new PhabricatorStandardPageView();
$view->appendChild('404 Not Found');
$view->setTitle('404 Not Found');
$response = new AphrontWebpageResponse();
$response->setContent($view->render());
$response->setHTTPResponseCode(404);
return $response;
}
return $response;
}
public function build404Controller() {
return new Phabricator404Controller($request);
return array(new Phabricator404Controller($this->getRequest()), array());
}

View file

@ -9,6 +9,7 @@
phutil_require_module('phabricator', 'aphront/applicationconfiguration');
phutil_require_module('phabricator', 'aphront/request');
phutil_require_module('phabricator', 'aphront/response/webpage');
phutil_require_module('phabricator', 'applications/base/controller/404');
phutil_require_module('phabricator', 'view/page/standard');
phutil_require_module('phutil', 'markup');

View file

@ -23,6 +23,7 @@ abstract class AphrontResponse {
private $request;
private $cacheable = false;
private $responseCode = 200;
public function setRequest($request) {
$this->request = $request;
@ -42,6 +43,15 @@ abstract class AphrontResponse {
return $this;
}
public function setHTTPResponseCode($code) {
$this->responseCode = $code;
return $this;
}
public function getHTTPResponseCode() {
return $this->responseCode;
}
public function getCacheHeaders() {
if ($this->cacheable) {
$epoch = time() + $this->cacheable;

View file

@ -0,0 +1,13 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/base/controller/base');
phutil_require_source('Phabricator404Controller.php');

View file

@ -55,6 +55,12 @@ $response = $application->willSendResponse($response);
$response->setRequest($request);
$response_string = $response->buildResponseString();
$code = $response->getHTTPResponseCode();
if ($code != 200) {
header("HTTP/1.0 {$code}");
}
$headers = $response->getCacheHeaders();
$headers = array_merge($headers, $response->getHeaders());
foreach ($headers as $header) {