🏗️」 wip: genEnv done and process in progress

This commit is contained in:
2025-05-16 16:59:31 +02:00
parent 67cf7a1c3a
commit 8762963315
4 changed files with 68 additions and 46 deletions

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:59:41 by adjoly #+# #+# */
/* Updated: 2025/05/09 11:06:38 by adjoly ### ########.fr */
/* Updated: 2025/05/16 12:08:03 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,6 +20,7 @@
#include <node/default.hpp>
#include <string>
#include <tomlpp.hpp>
#include <webserv.hpp>
namespace webserv {
namespace config {
@ -39,6 +40,23 @@ class Route {
std::string getUpRoot(void) { return _up_root; }
std::string getIndex(void) { return _index; }
std::map<std::string, std::string> *getCgi(void) { return _cgi; }
std::string getCgiPath(const std::string file) {
if (_cgi == not_nullptr)
return "";
size_t pos = file.find_last_of(".");
if (pos == file.length())
return "";
std::string ext = file.substr(pos + 1);
for (auto it = prange(_cgi)) {
if (ext == it->first) {
return it->second;
}
}
return "";
}
bool *getMethods(void) { return _methods; }

View File

@ -6,7 +6,7 @@
/* By: gadelbes <gadelbes@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/24 13:46:34 by gadelbes #+# #+# */
/* Updated: 2025/05/15 13:45:20 by adjoly ### ########.fr */
/* Updated: 2025/05/16 12:26:18 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -36,11 +36,19 @@ class Cgi : public server::AClientResource {
private:
void _initEnvp(void);
/**
* @brief Can be used to convert the _envp to a char** usable in execve
*
* @return A newly allocated char** with the env from _envp
*/
char **_genEnv(void);
std::map<std::string, std::string> _envp;
config::Route *_conf;
http::ARequest *_request;
std::string _script_path; // The full path of the script to be executed
std::string _cgi_path;
std::map<std::string, std::string> _envp; // The envp filled with _initEnvp
config::Route *_conf; // The configuration for the route used
http::ARequest *_request; // The requests that will be used for the cgi
};
}; // namespace webserv

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/12 17:13:39 by adjoly #+# #+# */
/* Updated: 2025/05/13 10:14:27 by adjoly ### ########.fr */
/* Updated: 2025/05/16 10:18:25 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -77,7 +77,7 @@ class ResourceManager {
delete (*it);
_res.erase(it);
}
// TODO throw or not - to see
// NOTE: throw or not - to see
}
protected: