cgi exec compare with file method

This commit is contained in:
hugogogo
2022-08-08 13:20:06 +02:00
parent 78c3ffa456
commit da1f4b6e37
5 changed files with 97 additions and 48 deletions

View File

@@ -43,7 +43,7 @@ Client::Client( Client const & src )
{
raw_request = src.raw_request;
response = src.response;
// buf = strdup(src.buf);
// buf = strdup(src.buf); // TODO: this doesn't work
body_size = src.body_size;
status = src.status;
return;
@@ -75,14 +75,9 @@ void Client::parse_request()
size_t pos;
// DEBUG
std::cout << "\n"
<< "request:\n" << raw_request
<< "START _______________________\n\n"
std::cout << "\nREQUEST _____________________\n"
<< raw_request
<< "\nSCRIPT PATH _________________\n"
<< "\npath:" << _request.script.path
<< "\npath_info:" << _request.script.info
<< "\n END _______________________\n";
<< "\n\n";
pos = (raw_request).find(CRLF CRLF);
sub = (raw_request).substr(0, pos);
@@ -92,7 +87,7 @@ std::cout << "\n"
_parse_request_headers(list);
_parse_request_body(pos + 4);
_parse_port_hostname(this->get_rq_headers("Host"));
// add "raw_request.clear()" after parsing ? for little less memory usage ?
raw_request.clear();
}
bool Client::fill_script_path(std::string script)
@@ -103,10 +98,10 @@ bool Client::fill_script_path(std::string script)
std::string tmp;
pos = path.find(script);
if (pos != std::string::npos)
if (pos == 0)
{
tmp = path.substr(0, pos + len);
_request.script.path = "./srcs/cgi-bin" + tmp; // TODO: deal with cgi path
_request.script.path = "./srcs" + tmp; // TODO: root path ?
_request.script.info = path.substr(pos + len);
return true;
}