WIP CGI monitered by epoll
+ OK, but some errors case need to be lookup
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
enum send_return
|
||||
{
|
||||
SEND_IN_PROGRESS, // unused
|
||||
SEND_IN_PROGRESS,
|
||||
SEND_COMPLETE,
|
||||
SEND_CLOSE,
|
||||
};
|
||||
@@ -40,9 +40,26 @@ int Webserv::_send_response(Client *client)
|
||||
|
||||
std::cerr << "send()\n";
|
||||
|
||||
_append_base_headers(client);
|
||||
if (!client->status)
|
||||
_construct_response(client);
|
||||
if (client->response.empty())
|
||||
{
|
||||
_append_base_headers(client);
|
||||
if (!client->status)
|
||||
{
|
||||
_construct_response(client);
|
||||
if (client->cgi_pipe_rfd)
|
||||
return SEND_IN_PROGRESS;
|
||||
}
|
||||
}
|
||||
else if (client->cgi_pipe_rfd)
|
||||
{
|
||||
// /*DEBUG*/ std::cout << "\n" B_PURPLE "[response]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
|
||||
// /*DEBUG*/ std::cout << "\n" B_PURPLE "[script output]:" RESET "\n"; ::print_special(script_output); std::cout << B_PURPLE "-----------" RESET "\n\n";
|
||||
_check_script_output(client, client->cgi_output); // FD_CGI : adjust for client->cgi_output;
|
||||
if (client->status < 400)
|
||||
client->response += client->cgi_output;
|
||||
// /*DEBUG*/ std::cout << "\n" B_PURPLE "[response + output]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
|
||||
}
|
||||
|
||||
_insert_status_line(client);
|
||||
if (client->status >= 400)
|
||||
_error_html_response(client);
|
||||
@@ -89,14 +106,7 @@ void Webserv::_construct_response(Client *client)
|
||||
path = _replace_url_root(client, client->get_rq_abs_path());
|
||||
if (_is_cgi(client, path))
|
||||
{
|
||||
script_output = _exec_cgi(client);
|
||||
//*DEBUG*/ std::cout << "\n" B_PURPLE "[response]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
|
||||
//*DEBUG*/ std::cout << "\n" B_PURPLE "[script output]:" RESET "\n"; ::print_special(script_output); std::cout << B_PURPLE "-----------" RESET "\n\n";
|
||||
_check_script_output(client, script_output);
|
||||
if (client->status < 400)
|
||||
client->response += script_output;
|
||||
//*DEBUG*/ std::cout << "\n" B_PURPLE "[response + output]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
|
||||
|
||||
_exec_cgi(client);
|
||||
return;
|
||||
}
|
||||
_process_method(client, path);
|
||||
|
||||
Reference in New Issue
Block a user