body write to CGI now monitored by epoll

+ kermit.jpg :)
This commit is contained in:
lperrey
2022-08-17 23:42:12 +02:00
parent 2613ca2e1a
commit b34e49311b
13 changed files with 302 additions and 193 deletions

View File

@@ -12,7 +12,11 @@ Client::Client()
request_complete(false),
assigned_server(NULL),
assigned_location(NULL),
cgi_pipe_rfd(0),
cgi_state(0),
cgi_pipe_w_to_child(0),
cgi_pipe_r_from_child(0),
cgi_pipe_w_to_parent(0),
cgi_pipe_r_from_parent(0),
cgi_pid(0),
_fd(0),
_port(""),
@@ -29,7 +33,11 @@ Client::Client(int afd, listen_socket *lsocket, std::string aport, std::string a
request_complete(false),
assigned_server(NULL),
assigned_location(NULL),
cgi_pipe_rfd(0),
cgi_state(0),
cgi_pipe_w_to_child(0),
cgi_pipe_r_from_child(0),
cgi_pipe_w_to_parent(0),
cgi_pipe_r_from_parent(0),
cgi_pid(0),
_fd(afd),
_port(aport),
@@ -87,7 +95,7 @@ void Client::parse_request_headers(std::vector<ServerConfig> &servers)
if (raw_request.find(CRLF CRLF) == NPOS)
return ;
header_complete = true;
clear_request(); // not mandatory
clear_request_vars(); // not mandatory
_parse_request_line();
if (status)
@@ -229,7 +237,7 @@ void Client::fill_script_path(std::string &path, size_t pos)
void Client::clear()
{
clear_request();
clear_request_vars();
raw_request.clear();
response.clear();
status = 0;
@@ -238,12 +246,10 @@ void Client::clear()
request_complete = false;
assigned_server = NULL;
assigned_location = NULL;
cgi_pipe_rfd = 0;
cgi_pid = 0;
cgi_output.clear();
clear_cgi_vars();
}
void Client::clear_request()
void Client::clear_request_vars()
{
clear_script();
_request.method = UNKNOWN;
@@ -264,6 +270,17 @@ void Client::clear_script()
_request.script.info.clear();
}
void Client::clear_cgi_vars()
{
cgi_state = false;
cgi_pipe_w_to_child = 0;
cgi_pipe_r_from_child = 0;
cgi_pipe_w_to_parent = 0;
cgi_pipe_r_from_parent = 0;
cgi_pid = 0;
cgi_output.clear();
}
// debug
void Client::print_client(std::string message)
{