diff --git a/core/http/request.cpp b/core/http/request.cpp index 0853264..97635ad 100644 --- a/core/http/request.cpp +++ b/core/http/request.cpp @@ -108,7 +108,7 @@ void Request::send_file(const String &p_file_path) { } void Request::send_error(int error_code) { - server->get_web_root()->send_error(error_code, this); + server->get_web_root()->handle_error_send_request(this, error_code); } void Request::reset() { diff --git a/core/http/web_node.cpp b/core/http/web_node.cpp index 3fd2ef2..886a4ff 100644 --- a/core/http/web_node.cpp +++ b/core/http/web_node.cpp @@ -2,6 +2,7 @@ #include "web_node.h" #include "request.h" +#include "http_enums.h" #include "core/settings/settings.h" @@ -70,6 +71,14 @@ void WebNode::set_database(Database *db) { void WebNode::handle_request_main(Request *request) { } +void WebNode::handle_error_send_request(Request *request, const int error_code) { + //this is a fallback error handler. + //Webroot implements a proper one + request->compiled_body = "Internal server error!"; + request->set_status_code(HTTP_STATUS_CODE_503_SERVICE_UNAVAILABLE); + request->send(); +} + void WebNode::create_validators() { } diff --git a/core/http/web_node.h b/core/http/web_node.h index 00dd9ab..95c8184 100644 --- a/core/http/web_node.h +++ b/core/http/web_node.h @@ -3,6 +3,7 @@ #include "core/nodes/node.h" #include "core/reference.h" +#include "core/variant.h" class Request; class Settings; @@ -31,6 +32,8 @@ public: #endif virtual void handle_request_main(Request *request); + virtual void handle_error_send_request(Request *request, const int error_code); + virtual void create_validators(); virtual void create_table(); diff --git a/core/http/web_root.cpp b/core/http/web_root.cpp index 9beac7c..44726a6 100644 --- a/core/http/web_root.cpp +++ b/core/http/web_root.cpp @@ -93,6 +93,10 @@ void WebRoot::handle_request_main(Request *request) { // normal routing WebRouterNode::handle_request_main(request); } +/* +void WebRoot::handle_error_send_request(Request *request, const int error_code) { + +}*/ bool WebRoot::try_send_wwwroot_file(Request *request) { const String &path = request->get_path_full(); diff --git a/core/http/web_root.h b/core/http/web_root.h index d0bdb96..694787f 100644 --- a/core/http/web_root.h +++ b/core/http/web_root.h @@ -35,6 +35,8 @@ public: static std::string default_generic_error_body; void handle_request_main(Request *request); + //void handle_error_send_request(Request *request, const int error_code); + bool try_send_wwwroot_file(Request *request); void send_error(int error_code, Request *request); void send_file(const std::string &path, Request *request);