Fixed big problem with CGI handling

+ remains somes minors problems
This commit is contained in:
lperrey
2022-08-17 01:11:20 +02:00
parent 4dc70373f8
commit ccc542f52b
9 changed files with 96 additions and 118 deletions

View File

@@ -223,16 +223,21 @@ void Webserv::_exec_script(Client *client, char *env[])
_epoll_update(client->get_cl_fd(), 0, EPOLL_CTL_DEL);
client->cgi_pipe_rfd = FD_RD_FR_CHLD;
struct cgi_pipe_rfd new_cgi_fd;
new_cgi_fd.fd = FD_RD_FR_CHLD;
new_cgi_fd.cgi_pid = pid;
new_cgi_fd.client = client;
_cgi_pipe_rfds.push_back(new_cgi_fd);
client->cgi_pid = pid;
}
}
#define STATUS_500 std::string("Status: 500" CRLF CRLF);
void Webserv::_check_script_output(Client *client, std::string & output)
{
size_t pos;
pos = client->cgi_output.find(CRLF CRLF);
if (pos == 0 || pos == NPOS)
{
client->status = 500;;
return;
}
_check_script_status(client, output);
if (client->status >= 400 && client->status < 600)
return;