diff --git a/includes/requests/HttpRequest.hpp b/includes/requests/HttpRequest.hpp index 8670da5..19e4983 100644 --- a/includes/requests/HttpRequest.hpp +++ b/includes/requests/HttpRequest.hpp @@ -6,7 +6,7 @@ /* By: mmoussou +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/14 14:14:39 by adjoly #+# #+# */ -/* Updated: 2025/04/17 18:48:25 by adjoly ### ########.fr */ +/* Updated: 2025/04/20 11:25:37 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,7 +24,7 @@ namespace server { class Client { public: Client(int, sockaddr_in, config::Server *); - ~Client(void); + virtual ~Client(void); void answer(void); @@ -36,7 +36,6 @@ class Client { http::IRequest *_request; http::Response *_response; config::Server *_conf; - Logger *_log; }; } // -namespace server diff --git a/src/requests_handling/HttpRequests.cpp b/src/requests_handling/HttpRequests.cpp index 1ac8959..89e9fbb 100644 --- a/src/requests_handling/HttpRequests.cpp +++ b/src/requests_handling/HttpRequests.cpp @@ -6,7 +6,7 @@ /* By: mmoussou parse(data); @@ -218,6 +222,10 @@ http::Delete::Delete(void) { } +http::Delete::~Delete(void) +{ +} + http::Delete::Delete(std::string &data) { this->parse(data); @@ -297,6 +305,10 @@ http::Post::Post(void) { } +http::Post::~Post(void) +{ +} + http::Post::Post(std::string &data) { this->parse(data); diff --git a/src/requests_handling/HttpResponse.cpp b/src/requests_handling/HttpResponse.cpp index 9fccdb4..e7549ff 100644 --- a/src/requests_handling/HttpResponse.cpp +++ b/src/requests_handling/HttpResponse.cpp @@ -6,7 +6,7 @@ /* By: mmoussou _fd = fd; - this->_client_addr = socket; - this->_conf = conf; - this->_log = log; - std::string received_data; char buffer[BUFFER_SIZE]; ssize_t bytes_received; @@ -57,7 +34,7 @@ Client::Client(int fd, sockaddr_in socket, config::Server *conf, Logger *log) while (buffer[bytes_received]); - this->getRequest(request_str); + this->_getRequest(received_data); } void Client::_getRequest(std::string request_str) @@ -91,8 +68,8 @@ void Client::answer(void) { std::string response; - if (this->_request == "GET" || this->_request == "DELETE" || this->_request == "POST") - response = this->_request.execute().str(); + 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

"; send(this->_fd, response.c_str(), response.length(), 0); @@ -101,6 +78,6 @@ void Client::answer(void) Client::~Client(void) { - delete this->_request; + delete (http::Get *)(this->_request); delete this->_response; } diff --git a/src/server/Socket.cpp b/src/server/Socket.cpp index 32ba835..3538eee 100644 --- a/src/server/Socket.cpp +++ b/src/server/Socket.cpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/17 11:58:42 by adjoly #+# #+# */ -/* Updated: 2025/04/18 09:37:32 by adjoly ### ########.fr */ +/* Updated: 2025/04/20 10:58:26 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ @@ -78,5 +78,5 @@ int Server::_createSocket(std::string host, int port) { } void Server::_handle_client(int fd, sockaddr_in client_addr, struct pollfd poll_fd) { - server::Client *client = new server::Client(fd, client_addr, ); + server::Client *client = new server::Client(fd, client_addr, NULL); }