From d5f41ef70ed00d9310732ff0ac4c777a3ba3c8e3 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 5 Nov 2013 15:25:12 -0800 Subject: [PATCH] Return HTTP 500, not HTTP 200, on exception pages Summary: Ref T4064. The response code here isn't normally relevant, but we can hit these via `git clone http://../`, etc., and it's clearly more correct to use HTTP 500. Test Plan: Added a fake `throw new Exception()` and verified I got an HTTP 500 response. Reviewers: jamesr, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4064 Differential Revision: https://secure.phabricator.com/D7507 --- .../AphrontDefaultApplicationConfiguration.php | 2 ++ src/applications/base/controller/PhabricatorController.php | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php index c6a55ce773..0b296962f7 100644 --- a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php @@ -222,6 +222,7 @@ class AphrontDefaultApplicationConfiguration $response = new AphrontWebpageResponse(); $response->setContent($view->render()); + $response->setHTTPResponseCode(500); return $response; } @@ -268,6 +269,7 @@ class AphrontDefaultApplicationConfiguration $response = new AphrontDialogResponse(); $response->setDialog($dialog); + $response->setHTTPResponseCode(500); return $response; } diff --git a/src/applications/base/controller/PhabricatorController.php b/src/applications/base/controller/PhabricatorController.php index 149f40ee25..5449546b0a 100644 --- a/src/applications/base/controller/PhabricatorController.php +++ b/src/applications/base/controller/PhabricatorController.php @@ -249,9 +249,10 @@ abstract class PhabricatorController extends AphrontController { $view->appendChild(hsprintf( '
%s
', $response->buildResponseString())); - $response = new AphrontWebpageResponse(); - $response->setContent($view->render()); - return $response; + $page_response = new AphrontWebpageResponse(); + $page_response->setContent($view->render()); + $page_response->setHTTPResponseCode($response->getHTTPResponseCode()); + return $page_response; } else { $response->getDialog()->setIsStandalone(true);