diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-11-15 23:43:55 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-02-16 01:20:38 +0100 |
| commit | 737ad84a0d7c7d6ade8b5251d120bffbe604df04 (patch) | |
| tree | 71f1aecc6a83f8ae0668b7cb795c29d593656cc4 | |
| parent | ad0ee9cef2497f3b17539565b01c091499416123 (diff) | |
Return 500 when some server error occurs.
| -rw-r--r-- | src/lib/http_server.cc | 5 | ||||
| -rw-r--r-- | src/lib/http_server.h | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/http_server.cc b/src/lib/http_server.cc index 294d350ac..cf3f9756a 100644 --- a/src/lib/http_server.cc +++ b/src/lib/http_server.cc @@ -38,6 +38,7 @@ using std::vector; Response Response::ERROR_404 = { 404, "<html><head><title>Error 404</title></head><body><h1>Error 404</h1></body></html>"}; +Response Response::ERROR_500 = { 500, "<html><head><title>Error 500</title></head><body><h1>Error 500</h1></body></html>"}; HTTPServer::HTTPServer(int port, int timeout) @@ -156,8 +157,8 @@ HTTPServer::request(vector<string> const& request) LOG_ERROR("Unknown exception while handling HTTP request"); } - LOG_HTTP("404 {}", parts[0]); - return Response::ERROR_404; + LOG_HTTP("500 {}", parts[0]); + return Response::ERROR_500; } diff --git a/src/lib/http_server.h b/src/lib/http_server.h index 4c8acdc11..ca4f498e4 100644 --- a/src/lib/http_server.h +++ b/src/lib/http_server.h @@ -46,6 +46,7 @@ public: void send(std::shared_ptr<Socket> socket); static Response ERROR_404; + static Response ERROR_500; private: int _code; |
