wip script output verification working
+ trim secure pos segfault + concat script message with server message
This commit is contained in:
@@ -102,8 +102,11 @@ std::string Webserv::_exec_script(Client *client, char **env)
|
||||
close(FD_RD_FR_CHLD);
|
||||
dup2(FD_RD_FR_PRNT, STDIN_FILENO);
|
||||
dup2(FD_WR_TO_PRNT, STDOUT_FILENO);
|
||||
//execve(client->get_rq_script_path().c_str(), nll, env);
|
||||
execve("truc", nll, env);
|
||||
// DEBUG
|
||||
std::cerr << "execve:\n";
|
||||
execve(client->get_rq_script_path().c_str(), nll, env);
|
||||
// for tests execve crash :
|
||||
//execve("wrong", nll, env);
|
||||
std::cerr << "execve crashed.\n";
|
||||
}
|
||||
else
|
||||
@@ -144,18 +147,32 @@ void Webserv::_check_script_status(Client *client, std::string output)
|
||||
{
|
||||
status_pos = pos + std::string("Status:").size();
|
||||
client->status = atoi(output.c_str() + status_pos);
|
||||
::delete_line_in_string(&output, pos, CRLF);
|
||||
::del_line_in_str(&output, pos, CRLF);
|
||||
}
|
||||
client->status = 200;
|
||||
}
|
||||
|
||||
void Webserv::_check_script_fields(Client *client, std::string output)
|
||||
{
|
||||
std::map<std::string, std::string> server_fields;
|
||||
std::map<std::string, std::string> script_fields;
|
||||
std::map<std::string, std::string> srv_fld; // server_field
|
||||
std::map<std::string, std::string> scr_fld; // script_field
|
||||
std::map<std::string, std::string>::iterator it_srv;
|
||||
std::map<std::string, std::string>::iterator it_scr;
|
||||
size_t pos;
|
||||
|
||||
server_fields = parse_http_headers(client->response);
|
||||
script_fields = parse_http_headers(output);
|
||||
// TODO: compare both map to supress duplicates
|
||||
srv_fld = parse_http_headers(client->response);
|
||||
scr_fld = parse_http_headers(output);
|
||||
// wip: compare both map to supress duplicates
|
||||
for (it_srv = srv_fld.begin(); it_srv != srv_fld.end(); it_srv++)
|
||||
{
|
||||
for (it_scr = scr_fld.begin(); it_scr != scr_fld.end(); it_scr++)
|
||||
{
|
||||
if (it_srv->first == it_scr->first)
|
||||
{
|
||||
pos = client->response.find(it_srv->first);
|
||||
::del_line_in_str(&client->response, pos, CRLF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user