diff --git a/includes/cgi.hpp b/includes/cgi.hpp index 90f9cce..558c8d9 100644 --- a/includes/cgi.hpp +++ b/includes/cgi.hpp @@ -6,13 +6,14 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/24 14:17:34 by adjoly #+# #+# */ -/* Updated: 2025/03/24 14:20:00 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 11:51:33 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once #include + class cgi { public: cgi(); diff --git a/includes/config/Config.hpp b/includes/config/Config.hpp index 52280d6..51eb335 100644 --- a/includes/config/Config.hpp +++ b/includes/config/Config.hpp @@ -6,13 +6,13 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/14 12:20:06 by adjoly #+# #+# */ -/* Updated: 2025/04/22 10:57:26 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 11:52:33 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#include "config/default.hpp" +#include namespace webserv { namespace config { diff --git a/includes/config/Route.hpp b/includes/config/Route.hpp index 5bb08cc..63e2cfd 100644 --- a/includes/config/Route.hpp +++ b/includes/config/Route.hpp @@ -6,15 +6,15 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/19 14:59:41 by adjoly #+# #+# */ -/* Updated: 2025/04/18 10:05:22 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 11:49:19 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#include "cppeleven.hpp" -#include "log.hpp" -#include "node/default.hpp" +#include +#include +#include #include #include #include diff --git a/includes/config/Server.hpp b/includes/config/Server.hpp index 8bdc37d..7280e50 100644 --- a/includes/config/Server.hpp +++ b/includes/config/Server.hpp @@ -6,16 +6,16 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/19 14:11:28 by adjoly #+# #+# */ -/* Updated: 2025/04/22 10:59:27 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 12:02:36 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#include "config/default.hpp" -#include "cppeleven.hpp" -#include "node/ANode.hpp" -#include "webserv.hpp" +#include +#include +#include +#include namespace webserv { namespace config { diff --git a/includes/config/default.hpp b/includes/config/default.hpp index 7713797..14c8d43 100644 --- a/includes/config/default.hpp +++ b/includes/config/default.hpp @@ -6,18 +6,18 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/19 14:15:51 by adjoly #+# #+# */ -/* Updated: 2025/04/14 12:54:29 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 12:03:30 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#include "Route.hpp" -#include "Server.hpp" -#include "Config.hpp" -#include "cppeleven.hpp" -#include "node/Table.hpp" -#include "node/default.hpp" +#include +#include +#include +#include +#include +#include #include namespace webserv { diff --git a/includes/log.hpp b/includes/log.hpp index f3ac4cb..d9aaa5a 100644 --- a/includes/log.hpp +++ b/includes/log.hpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/20 09:28:27 by adjoly #+# #+# */ -/* Updated: 2025/04/18 10:03:06 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 11:50:42 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/includes/requests/Errors.hpp b/includes/requests/Errors.hpp index a31b50b..e2b2e46 100644 --- a/includes/requests/Errors.hpp +++ b/includes/requests/Errors.hpp @@ -6,13 +6,11 @@ /* By: mmoussou #include @@ -37,5 +35,3 @@ private: } // -namespace http } // -namespace webserv - -#endif // __WEBSERV_REQUESTS_ERRORS_HPP__ diff --git a/includes/requests/HttpIMessage.hpp b/includes/requests/HttpIMessage.hpp index 9ed38b2..a357f8d 100644 --- a/includes/requests/HttpIMessage.hpp +++ b/includes/requests/HttpIMessage.hpp @@ -6,13 +6,11 @@ /* By: mmoussou #include @@ -43,5 +41,3 @@ protected: } // -namespace http } // -namespace webserv - -#endif // __WEBSERV_REQUESTS_HTTP_IMESSAGE_HPP__ diff --git a/includes/requests/HttpRequest.hpp b/includes/requests/HttpRequest.hpp index 19e4983..4a811c0 100644 --- a/includes/requests/HttpRequest.hpp +++ b/includes/requests/HttpRequest.hpp @@ -6,13 +6,11 @@ /* By: mmoussou #include @@ -22,6 +20,8 @@ #include #include +#include + namespace webserv { namespace http { @@ -37,15 +37,18 @@ public: std::string getMethod(void) const; std::string getTarget(void) const; std::string getProtocol(void) const; + config::Server *getConfig(void) const; void setMethod(std::string const method); void setTarget(std::string const target); void setProtocol(std::string const protocol); + void setServer(std::string const protocol); protected: std::string _method; std::string _target; std::string _protocol; + config::Server *_conf; }; @@ -87,5 +90,3 @@ public: } // -namespace http } // -namespace webserv - -#endif // __WEBSERV_REQUESTS_HTTP_REQUEST_HPP__ diff --git a/includes/requests/HttpResponse.hpp b/includes/requests/HttpResponse.hpp index 698b1ac..cf44d32 100644 --- a/includes/requests/HttpResponse.hpp +++ b/includes/requests/HttpResponse.hpp @@ -6,13 +6,11 @@ /* By: mmoussou @@ -46,5 +44,3 @@ private: } // -namespace http } // -namespace webserv - -#endif // __WEBSERV_REQUESTS_HTTP_RESPONSE_HPP__ diff --git a/includes/requests/default.hpp b/includes/requests/default.hpp index 82636b6..6359f52 100644 --- a/includes/requests/default.hpp +++ b/includes/requests/default.hpp @@ -6,18 +6,14 @@ /* By: mmoussou #include #include using namespace webserv; - -#endif // __WEBSERV_REQUESTS_DEFAULT_HPP__ diff --git a/includes/server/Client.hpp b/includes/server/Client.hpp index d0998e6..035a1fe 100644 --- a/includes/server/Client.hpp +++ b/includes/server/Client.hpp @@ -6,15 +6,15 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/14 14:14:39 by adjoly #+# #+# */ -/* Updated: 2025/04/20 11:25:37 by mmoussou ### ########.fr */ +/* Updated: 2025/04/22 12:04:57 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#include "config/default.hpp" -#include "default.hpp" -#include "requests/default.hpp" +#include +#include +#include #include #include @@ -23,7 +23,7 @@ namespace server { class Client { public: - Client(int, sockaddr_in, config::Server *); + Client(int, sockaddr_in, config::Config *); virtual ~Client(void); void answer(void); diff --git a/includes/server/Server.hpp b/includes/server/Server.hpp index bea5532..2d13f61 100644 --- a/includes/server/Server.hpp +++ b/includes/server/Server.hpp @@ -6,13 +6,13 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/11 17:45:43 by adjoly #+# #+# */ -/* Updated: 2025/04/21 10:46:31 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 11:51:27 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#include "log.hpp" +#include #include #include #include diff --git a/includes/server/default.hpp b/includes/server/default.hpp index 739752a..76c1351 100644 --- a/includes/server/default.hpp +++ b/includes/server/default.hpp @@ -6,14 +6,14 @@ /* By: mmoussou +#include namespace webserv { diff --git a/includes/webserv.hpp b/includes/webserv.hpp index 557b577..0f9654b 100644 --- a/includes/webserv.hpp +++ b/includes/webserv.hpp @@ -6,7 +6,7 @@ /* By: mmoussou #include "node/default.hpp" #include #include diff --git a/src/help.cpp b/src/help.cpp index 56b42d1..2982778 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -6,11 +6,11 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/10 13:08:36 by adjoly #+# #+# */ -/* Updated: 2025/04/11 11:39:00 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 11:47:39 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ -#include "log.hpp" +#include #include #include #include diff --git a/src/server/Client.cpp b/src/server/Client.cpp index a79bde6..f974dc7 100644 --- a/src/server/Client.cpp +++ b/src/server/Client.cpp @@ -6,7 +6,7 @@ /* By: mmoussou _getRequest(received_data); + + this->_conf = conf->getServer(this->_request->getHeaders()["Host"]); + + + //if (received_data.length > (get max_body_size from Route corresponding) ) + // throw error } void Client::_getRequest(std::string request_str) @@ -67,6 +73,7 @@ void Client::_getRequest(std::string request_str) void Client::answer(void) { std::string response; + (void) _client_addr; if (this->_request->getMethod() == "GET" || this->_request->getMethod() == "DELETE" || this->_request->getMethod() == "POST") response = this->_request->execute().str(); diff --git a/src/server/ServerUtils.cpp b/src/server/ServerUtils.cpp index b1879fb..e34ac98 100644 --- a/src/server/ServerUtils.cpp +++ b/src/server/ServerUtils.cpp @@ -1,16 +1,16 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* Socket.cpp :+: :+: :+: */ +/* ServerUtils.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/17 11:58:42 by adjoly #+# #+# */ -/* Updated: 2025/04/21 10:53:45 by adjoly ### ########.fr */ +/* Updated: 2025/04/22 11:46:07 by mmoussou ### ########.fr */ /* */ /* ************************************************************************** */ -#include "server/Client.hpp" +#include #include #include #include @@ -81,7 +81,7 @@ bool Server::_handle_client(struct pollfd &pollfd, sockaddr_in *sock_data) { Client *client; try { - client = new Client(pollfd.fd, sock_data, _conf); + client = new Client(pollfd.fd, *sock_data, _conf); client->answer(); } catch (std::exception &e) { _log->error(e.what());