in _is_cgi, fix error in return http error status
+ fix error in checking script output : reverse order between calcul of content_length and erasing empty line
This commit is contained in:
@@ -5,7 +5,7 @@ bool Webserv::_is_cgi(Client *client, std::string path)
|
||||
{
|
||||
std::string script_path;
|
||||
size_t file_type;
|
||||
size_t file_mode;
|
||||
size_t file_mode = client->status;
|
||||
size_t pos = 0;
|
||||
|
||||
while (pos != NPOS)
|
||||
@@ -160,7 +160,6 @@ std::string Webserv::_exec_script(Client *client, char **env)
|
||||
// for tests execve crash :
|
||||
//execve("wrong", nll, env);
|
||||
std::cerr << "execve crashed.\n";
|
||||
|
||||
// TODO HUGO : check errno
|
||||
}
|
||||
else //parent
|
||||
@@ -189,8 +188,8 @@ void Webserv::_check_script_output(Client *client, std::string & output)
|
||||
{
|
||||
_check_script_status(client, output);
|
||||
_check_script_fields(client, output);
|
||||
_add_script_body_length_header(output);
|
||||
_remove_body_leading_empty_lines(output);
|
||||
_add_script_body_length_header(output);
|
||||
// _check_script_empty_lines(client, output);
|
||||
// _check_script_space_colons(client, output);
|
||||
// _check_script_new_lines(client, output);
|
||||
|
||||
@@ -47,7 +47,7 @@ int Webserv::_send_response(Client *client)
|
||||
if (client->status >= 400)
|
||||
_error_html_response(client);
|
||||
|
||||
/*DEBUG*/ std::cout << "\n" B_PURPLE "[response + output + headers]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
|
||||
/*DEBUG*/ std::cout << "\n" B_PURPLE "[response + output + headers]:" RESET "\n"; ::print_special(client->response); std::cout << "\n" B_PURPLE "-----------" RESET "\n\n";
|
||||
|
||||
std::cerr << "client->response.size() = " << client->response.size() << "\n"; // DEBUG
|
||||
ret = ::send(client->get_cl_fd(), client->response.c_str(), client->response.size(), 0);
|
||||
@@ -86,13 +86,14 @@ void Webserv::_construct_response(Client *client)
|
||||
{
|
||||
script_output = _exec_cgi(client);
|
||||
|
||||
/*DEBUG*/ std::cout << "\n" B_PURPLE "[script output]:" RESET "\n"; ::print_special(script_output); std::cout << B_PURPLE "-----------" RESET "\n\n";
|
||||
/*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";
|
||||
///*DEBUG*/ std::cout << "\n" B_PURPLE "[response]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
|
||||
|
||||
_check_script_output(client, script_output);
|
||||
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";
|
||||
/*DEBUG*/ std::cout << B_YELLOW "inside cgi" RESET "\n";
|
||||
///*DEBUG*/ std::cout << "\n" B_PURPLE "[response + output]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user