From 1dc3a61b01b57fb618f7c0fe5c1f983c71fc7100 Mon Sep 17 00:00:00 2001 From: adjoly Date: Wed, 23 Apr 2025 17:34:22 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=8F=97=EF=B8=8F=E3=80=8D=20wip:?= =?UTF-8?q?=20nothing=20is=20working=20anymore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exemples/default.toml | 2 +- includes/config/URL.hpp | 19 +++++++++++++++---- includes/{cgi.hpp => requests/Cgi.hpp} | 24 ++++++++++++++++++------ 3 files changed, 34 insertions(+), 11 deletions(-) rename includes/{cgi.hpp => requests/Cgi.hpp} (70%) diff --git a/exemples/default.toml b/exemples/default.toml index 531a1af..879d5c7 100644 --- a/exemples/default.toml +++ b/exemples/default.toml @@ -1,5 +1,5 @@ [server] -host = "localhost" +host = "0.0.0.0" port = 8080 [server.location./] diff --git a/includes/config/URL.hpp b/includes/config/URL.hpp index f5a7a50..3295abb 100644 --- a/includes/config/URL.hpp +++ b/includes/config/URL.hpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/22 12:17:48 by adjoly #+# #+# */ -/* Updated: 2025/04/22 12:42:21 by adjoly ### ########.fr */ +/* Updated: 2025/04/23 17:24:51 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,11 +30,13 @@ class URL { std::vector getSegments(void) { return _path_segments; } std::string getFullUrl(void) { return _full_url; } + std::string getQueryString(void) const { return _query_string; } private: void parse() { size_t scheme_pos = _full_url.find("://"); size_t path_start = 0; + size_t query_start = _full_url.find('?'); if (scheme_pos != std::string::npos) { path_start = _full_url.find('/', scheme_pos + 3); @@ -42,9 +44,17 @@ class URL { path_start = 0; } - if (path_start != std::string::npos) { - std::string path = _full_url.substr(path_start); - splitPath(path, _path_segments); + if (query_start != std::string::npos) { + _query_string = _full_url.substr(query_start + 1); + if (path_start != std::string::npos) { + std::string path = _full_url.substr(path_start, query_start - path_start); + splitPath(path, _path_segments); + } + } else { + if (path_start != std::string::npos) { + std::string path = _full_url.substr(path_start); + splitPath(path, _path_segments); + } } } @@ -72,4 +82,5 @@ class URL { std::string _full_url; std::vector _path_segments; + std::string _query_string; }; diff --git a/includes/cgi.hpp b/includes/requests/Cgi.hpp similarity index 70% rename from includes/cgi.hpp rename to includes/requests/Cgi.hpp index 558c8d9..4f901c0 100644 --- a/includes/cgi.hpp +++ b/includes/requests/Cgi.hpp @@ -1,24 +1,36 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* cgi.hpp :+: :+: :+: */ +/* Cgi.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/24 14:17:34 by adjoly #+# #+# */ -/* Updated: 2025/04/22 11:51:33 by mmoussou ### ########.fr */ +/* Updated: 2025/04/23 17:27:45 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#include +#include "requests/HttpIMessage.hpp" +#include +#include -class cgi { +namespace webserv { + + +class Cgi { public: - cgi(); - ~cgi(void); + Cgi(http::IMessage &); + ~Cgi(void); + + void initEnvp(void); + protected: private: + std::map _envp; + + std::string _request; }; +};