fixed pbm in extract_line : delete the line and the newline sequence character

+ fixed pbm n _cgi_pos : last return is npos, not pos
This commit is contained in:
hugogogo
2022-08-13 12:39:05 +02:00
parent f17bc9fa58
commit defb2ada61
4 changed files with 14 additions and 16 deletions

View File

@@ -8,32 +8,27 @@ size_t Webserv::_cgi_pos(Client *client, std::string &path)
std::vector<std::string>::const_iterator it;
std::vector<std::string>::const_iterator it_end;
size_t pos = 0;
/*DEBUG*/ it = client->assigned_location->cgi_ext.begin(); std::cout << B_YELLOW << "\nDEBUG _cgi_pos()\n" << RESET << "vector_ext.size():[" << client->assigned_location->cgi_ext.size() << "]\n\n";
v_ext = client->assigned_location->cgi_ext;
if (v_ext.empty())
return NPOS;
/*DEBUG*/ std::cout << "ext:[" << *it << "]\n" << "path:[" << path << "]\n\n";
return NPOS; /*DEBUG*/ std::cout << "ext:[" << *it << "]\n" << "path:[" << path << "]\n\n";
it_end = client->assigned_location->cgi_ext.end();
while (pos < path.size())
{
/*DEBUG*/ std::cout << "\nwhile\n";
{ /*DEBUG*/ std::cout << "\nwhile\n";
if (path.compare(pos, 2, "./") == 0)
pos += 2;
/*DEBUG*/ std::cout << "&path[pos]:[" << &path[pos] << "]\n";
pos += 2; /*DEBUG*/ std::cout << "&path[pos]:[" << &path[pos] << "]\n";
pos = path.find('.', pos);
if (pos == NPOS)
return pos;
it = client->assigned_location->cgi_ext.begin();
for ( ; it != it_end; ++it)
{
/*DEBUG*/ std::cout << " for\n"; std::cout << " &path[pos]:[" << &path[pos] << "]\n" << " *it:[" << *it << "]\n" << " (*it).size():[" << (*it).size() << "]\n" << " path.substr(pos, (*it).size()):[" << path.substr(pos + 1, (*it).size()) << "]\n\n";
{ /*DEBUG*/ std::cout << " for\n"; std::cout << " &path[pos]:[" << &path[pos] << "]\n" << " *it:[" << *it << "]\n" << " (*it).size():[" << (*it).size() << "]\n" << " path.substr(pos, (*it).size()):[" << path.substr(pos + 1, (*it).size()) << "]\n\n";
if (path.compare(pos + 1, (*it).size(), *it) == 0)
return pos;
}
pos++;
}
return pos;
return NPOS;
}
std::string Webserv::_exec_cgi(Client *client)