From 69efca1a157245b35cd80a09718f45b30412dcea Mon Sep 17 00:00:00 2001 From: Pixel Date: Thu, 8 Dec 2011 08:20:07 -0800 Subject: Moving the HTTP status messages out of the HTTP server, and into its own file. Also making it complete. --- src/HttpServer.cc | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'src/HttpServer.cc') diff --git a/src/HttpServer.cc b/src/HttpServer.cc index ee6919b..1268c7b 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -176,25 +176,11 @@ void Balau::HttpWorker::readVariables(Http::StringMap & variables, char * str) { } while (ampPos); } -static const char * getErrorMsg(int httpError) { - switch (httpError) { - case 400: - return "Bad Request"; - case 403: - return "Forbidden"; - case 404: - return "Not Found"; - case 405: - return "Method Not Allowed"; - case 500: - default: - return "Internal Error"; - } -} - void Balau::HttpWorker::sendError(int error, const char * msg, const char * details, bool closeConnection, std::vector extraHeaders, std::vector trace) { SimpleMustache * tpl = &m_errorTemplate; - const char * errorMsg = getErrorMsg(error); + const char * errorMsg = Http::getStatusMsg(error); + if (!errorMsg) + errorMsg = "Unknown Status"; Printer::elog(Balau::E_HTTPSERVER, "%s caused a %i error (%s)", m_name.to_charp(), error, errorMsg); SimpleMustache::Context ctx; String title; -- cgit v1.2.3