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:
@@ -1,6 +1,10 @@
|
||||
|
||||
## work together
|
||||
|
||||
#### next commit
|
||||
+ fixed pbm in extract_line : delete the line and the newline sequence character
|
||||
+ fixed pbm n _cgi_pos : last return is npos, not pos
|
||||
|
||||
#### TODO hugo
|
||||
- `_is_cgi()` and `_fill_cgi_path()`
|
||||
- two cgi tests :
|
||||
|
||||
@@ -198,8 +198,8 @@ std::string str_tolower(std::string str)
|
||||
}
|
||||
|
||||
// identify a line in a string, by delim (ex. '\n')
|
||||
// delete this line from the string
|
||||
// and return the deleted line
|
||||
// delete this line from the string (and the following nl sequence characters)
|
||||
// and return the deleted line (without the followinf nl sequence characters)
|
||||
std::string
|
||||
extract_line(std::string & str, size_t pos, std::string delim)
|
||||
{
|
||||
@@ -220,7 +220,7 @@ std::string
|
||||
len = end - begin;
|
||||
|
||||
del_str = str.substr(begin, len);
|
||||
str.erase(begin, len);
|
||||
str.erase(begin, len + delim.size());
|
||||
return del_str;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -71,10 +71,9 @@ void Webserv::_construct_response(Client *client)
|
||||
{
|
||||
std::string path = _replace_url_root(client, client->get_rq_abs_path());
|
||||
|
||||
size_t pos = _cgi_pos(client, path);
|
||||
//debug
|
||||
std::cout << "pos:" << pos << B_YELLOW << "\nfin debug _cgi_pos()\n\n" << RESET;
|
||||
size_t pos = _cgi_pos(client, path); /*DEBUG*/ std::cout << "pos:" << pos << B_YELLOW << "\nfin debug _cgi_pos()\n\n" << RESET;
|
||||
(void)pos;
|
||||
|
||||
// if (pos != NPOS)
|
||||
// {
|
||||
// client->fill_script_path(path, pos);
|
||||
|
||||
Reference in New Issue
Block a user