mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-05-10 23:48:46 +02:00
「🏗️」 wip: Started cgi handling but no clue what i am doing
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/22 12:17:48 by adjoly #+# #+# */
|
||||
/* Updated: 2025/04/23 17:24:51 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/04/24 14:01:15 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,31 +6,36 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/24 14:17:34 by adjoly #+# #+# */
|
||||
/* Updated: 2025/04/23 17:27:45 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/04/24 14:24:09 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "requests/HttpIMessage.hpp"
|
||||
#include "requests/HttpRequest.hpp"
|
||||
#include <config/default.hpp>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace webserv {
|
||||
|
||||
|
||||
class Cgi {
|
||||
public:
|
||||
Cgi(http::IMessage &);
|
||||
Cgi(http::IRequest *, config::Server *);
|
||||
~Cgi(void);
|
||||
|
||||
void initEnvp(void);
|
||||
std::string getEnv(std::string &);
|
||||
void setEnv(std::string &, std::string);
|
||||
|
||||
void process(void);
|
||||
|
||||
protected:
|
||||
private:
|
||||
void _initEnvp(void);
|
||||
|
||||
std::map<std::string, std::string> _envp;
|
||||
|
||||
|
||||
std::string _request;
|
||||
};
|
||||
config::Server *_conf;
|
||||
http::IMessage *_request;
|
||||
};
|
||||
}; // namespace webserv
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/03 15:48:22 by mmoussou #+# #+# */
|
||||
/* Updated: 2025/04/22 11:51:54 by mmoussou ### ########.fr */
|
||||
/* Updated: 2025/04/24 13:48:09 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -15,5 +15,6 @@
|
||||
#include <requests/Errors.hpp>
|
||||
#include <requests/HttpRequest.hpp>
|
||||
#include <requests/HttpResponse.hpp>
|
||||
#include <requests/Cgi.hpp>
|
||||
|
||||
using namespace webserv;
|
||||
|
50
src/requests_handling/Cgi.cpp
Normal file
50
src/requests_handling/Cgi.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Cgi.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/24 13:46:34 by adjoly #+# #+# */
|
||||
/* Updated: 2025/04/24 14:38:20 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "requests/HttpIMessage.hpp"
|
||||
#include "requests/HttpRequest.hpp"
|
||||
#include "requests/HttpResponse.hpp"
|
||||
#include "requests/default.hpp"
|
||||
|
||||
Cgi::Cgi(http::IRequest *req, config::Server *conf) : _conf(conf), _request(req) {
|
||||
_initEnvp();
|
||||
}
|
||||
|
||||
void Cgi::_initEnvp(void) {
|
||||
_envp[] = "";
|
||||
}
|
||||
|
||||
std::string Cgi::getEnv(std::string &key) {
|
||||
auto it = _envp.find(key);
|
||||
if (it != _envp.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void Cgi::setEnv(std::string &key, std::string value) {
|
||||
_envp[key] = value;
|
||||
}
|
||||
|
||||
void Cgi::process() {
|
||||
int pipefd[2];
|
||||
int forkPid;
|
||||
|
||||
if (pipe(pipefd) <= -1) {
|
||||
//throw error
|
||||
}
|
||||
|
||||
forkPid = fork();
|
||||
if (forkPid == 0) {
|
||||
// in fork
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user