mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 16:30:59 +01:00
Somewhat proper 404 page, plus HTTP response code.
This commit is contained in:
parent
9f04548ab9
commit
6c37f918b1
5 changed files with 40 additions and 1 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -23,6 +23,7 @@ abstract class AphrontResponse {
|
|||
|
||||
private $request;
|
||||
private $cacheable = false;
|
||||
private $responseCode = 200;
|
||||
|
||||
public function setRequest($request) {
|
||||
$this->request = $request;
|
||||
|
@ -41,6 +42,15 @@ abstract class AphrontResponse {
|
|||
$this->cacheable = $duration;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHTTPResponseCode($code) {
|
||||
$this->responseCode = $code;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHTTPResponseCode() {
|
||||
return $this->responseCode;
|
||||
}
|
||||
|
||||
public function getCacheHeaders() {
|
||||
if ($this->cacheable) {
|
||||
|
|
13
src/applications/base/controller/404/__init__.php
Normal file
13
src/applications/base/controller/404/__init__.php
Normal 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');
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue