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:
@@ -31,11 +31,11 @@ server {
|
|||||||
upload_dir ./www/uploaded/;
|
upload_dir ./www/uploaded/;
|
||||||
}
|
}
|
||||||
|
|
||||||
# location /srcs/cgi-bin/ {
|
location /srcs/cgi-bin/ {
|
||||||
# root ./srcs/cgi-bin/;
|
root ./srcs/cgi-bin/;
|
||||||
# allow_methods POST;
|
allow_methods POST;
|
||||||
# cgi_ext php;
|
cgi_ext php;
|
||||||
# }
|
}
|
||||||
|
|
||||||
location /list {
|
location /list {
|
||||||
autoindex on;
|
autoindex on;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ bool Webserv::_is_cgi(Client *client, std::string path)
|
|||||||
{
|
{
|
||||||
std::string script_path;
|
std::string script_path;
|
||||||
size_t file_type;
|
size_t file_type;
|
||||||
size_t file_mode;
|
size_t file_mode = client->status;
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
|
||||||
while (pos != NPOS)
|
while (pos != NPOS)
|
||||||
@@ -160,7 +160,6 @@ std::string Webserv::_exec_script(Client *client, char **env)
|
|||||||
// for tests execve crash :
|
// for tests execve crash :
|
||||||
//execve("wrong", nll, env);
|
//execve("wrong", nll, env);
|
||||||
std::cerr << "execve crashed.\n";
|
std::cerr << "execve crashed.\n";
|
||||||
|
|
||||||
// TODO HUGO : check errno
|
// TODO HUGO : check errno
|
||||||
}
|
}
|
||||||
else //parent
|
else //parent
|
||||||
@@ -189,8 +188,8 @@ void Webserv::_check_script_output(Client *client, std::string & output)
|
|||||||
{
|
{
|
||||||
_check_script_status(client, output);
|
_check_script_status(client, output);
|
||||||
_check_script_fields(client, output);
|
_check_script_fields(client, output);
|
||||||
_add_script_body_length_header(output);
|
|
||||||
_remove_body_leading_empty_lines(output);
|
_remove_body_leading_empty_lines(output);
|
||||||
|
_add_script_body_length_header(output);
|
||||||
// _check_script_empty_lines(client, output);
|
// _check_script_empty_lines(client, output);
|
||||||
// _check_script_space_colons(client, output);
|
// _check_script_space_colons(client, output);
|
||||||
// _check_script_new_lines(client, output);
|
// _check_script_new_lines(client, output);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ int Webserv::_send_response(Client *client)
|
|||||||
if (client->status >= 400)
|
if (client->status >= 400)
|
||||||
_error_html_response(client);
|
_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
|
std::cerr << "client->response.size() = " << client->response.size() << "\n"; // DEBUG
|
||||||
ret = ::send(client->get_cl_fd(), client->response.c_str(), client->response.size(), 0);
|
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);
|
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 "[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 "[response]:" RESET "\n"; ::print_special(client->response); std::cout << B_PURPLE "-----------" RESET "\n\n";
|
||||||
|
|
||||||
_check_script_output(client, script_output);
|
_check_script_output(client, script_output);
|
||||||
client->response += 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user