🔨」 fix(requests/Errors): now working, kinda

This commit is contained in:
y-syo
2025-03-24 16:01:45 +01:00
parent 7c2a6e10e2
commit 78ee544eb3
2 changed files with 9 additions and 9 deletions

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */ /* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/16 17:51:46 by mmoussou #+# #+# */ /* Created: 2025/03/16 17:51:46 by mmoussou #+# #+# */
/* Updated: 2025/03/19 02:05:59 by mmoussou ### ########.fr */ /* Updated: 2025/03/24 15:05:53 by mmoussou ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -29,8 +29,9 @@ namespace http {
class Errors { class Errors {
public: public:
static http::Response &getRequest(int error_code); //static http::Response &getRequest(int error_code);
static void setEntry(const std::string &key, int value); static std::string getResponseBody(int error_code);
static void setEntry(const std::string &key, int value);
static std::map<int, std::string> message; static std::map<int, std::string> message;
private: private:

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */ /* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/17 14:08:12 by mmoussou #+# #+# */ /* Created: 2025/03/17 14:08:12 by mmoussou #+# #+# */
/* Updated: 2025/03/19 01:51:36 by mmoussou ### ########.fr */ /* Updated: 2025/03/24 15:12:50 by mmoussou ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,15 +14,14 @@
using namespace webserv; using namespace webserv;
http::Response &http::Errors::getRequest(int error_code) std::string http::Errors::getResponseBody(int error_code)
{ {
http::Response *result = new http::Response; std::string body;
if (http::Errors::set_error_pages.find(error_code) != http::Errors::set_error_pages.end()) if (http::Errors::set_error_pages.find(error_code) != http::Errors::set_error_pages.end())
result->setBody(Errors::set_error_pages[error_code]); return(Errors::set_error_pages[error_code]);
else else
result->setBody("<html><body><h1>" + http::Errors::message[error_code] + "</h1></body></html>"); return("<html><body><h1>" + http::Errors::message[error_code] + "</h1></body></html>");
return (*result);
} }
std::map<int, std::string> http::Errors::message = Errors::populateMessages(); std::map<int, std::string> http::Errors::message = Errors::populateMessages();