diff --git a/includes/requests/HttpIMessage.hpp b/includes/requests/HttpIMessage.hpp index eb63d3e..60511ee 100644 --- a/includes/requests/HttpIMessage.hpp +++ b/includes/requests/HttpIMessage.hpp @@ -6,7 +6,7 @@ /* By: mmoussou getHeaders(void) const; virtual std::string getBody(void) const; + virtual ~IMessage() {} + virtual void setHeaders(std::map const headers); virtual void setBody(std::string const body); diff --git a/includes/requests/HttpResponse.hpp b/includes/requests/HttpResponse.hpp index cf44d32..8ac7e33 100644 --- a/includes/requests/HttpResponse.hpp +++ b/includes/requests/HttpResponse.hpp @@ -6,7 +6,7 @@ /* By: mmoussou +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/14 14:14:39 by adjoly #+# #+# */ -/* Updated: 2025/04/22 14:23:44 by adjoly ### ########.fr */ +/* Updated: 2025/04/23 14:39:16 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,7 +34,7 @@ class Client { int _fd; struct sockaddr_in _client_addr; http::IRequest *_request; - http::Response *_response; + //http::Response *_response; config::Server *_conf; }; diff --git a/src/requests_handling/HttpResponse.cpp b/src/requests_handling/HttpResponse.cpp index e7549ff..c38e4ec 100644 --- a/src/requests_handling/HttpResponse.cpp +++ b/src/requests_handling/HttpResponse.cpp @@ -6,7 +6,7 @@ /* By: mmoussou error("failed to receive request"); - continue; + throw std::runtime_error("failed to receive request"); } received_data += std::string(buffer, bytes_received); } while (buffer[bytes_received]); @@ -59,21 +59,18 @@ void Client::_getRequest(std::string request_str) { } void Client::answer(void) { + (void) _client_addr; std::string response; - (void)_client_addr; if (this->_request->getMethod() == "GET" || this->_request->getMethod() == "DELETE" || this->_request->getMethod() == "POST") response = this->_request->execute().str(); else - response = "HTTP/1.1 501 Not Implemented\r\nContent-Type: " - "text/html\r\n\r\n

501 Not " - "Implemented

"; + response = "HTTP/1.1 501 Not Implemented\r\nContent-Type: text/html\r\n\r\n

501 Not Implemented

"; send(this->_fd, response.c_str(), response.length(), 0); } Client::~Client(void) { delete (http::Get *)(this->_request); - delete this->_response; }