changed del_line_in_str to etract_line
This commit is contained in:
@@ -151,10 +151,14 @@ std::string str_tolower(std::string str)
|
||||
return str;
|
||||
}
|
||||
|
||||
void del_line_in_str(std::string * str, size_t pos, std::string delim)
|
||||
// identify a line in a string, by delim (ex. '\n')
|
||||
// delete this line from the string
|
||||
// and return the deleted line
|
||||
std::string extract_line(std::string * str, size_t pos, std::string delim)
|
||||
{
|
||||
size_t begin;
|
||||
size_t end;
|
||||
std::string del_str;
|
||||
size_t begin;
|
||||
size_t end;
|
||||
|
||||
begin = (*str).rfind(delim, pos);
|
||||
if (begin == std::string::npos)
|
||||
@@ -168,10 +172,18 @@ void del_line_in_str(std::string * str, size_t pos, std::string delim)
|
||||
else
|
||||
end += delim.size();
|
||||
|
||||
del_str = (*str).substr(begin, end - begin);
|
||||
(*str).erase(begin, end - begin);
|
||||
return del_str;
|
||||
}
|
||||
|
||||
|
||||
// transform a str, like a http header, into a map
|
||||
// with <keys> delim <values>
|
||||
// and perform an action on keys and values
|
||||
// action receives address of keys and values, and return bool error :
|
||||
// bool action(&keys, &values)
|
||||
//std::map<std:string, std::string>
|
||||
// str_to_map(str, delim, action = NULL)
|
||||
|
||||
bool operator==(const listen_socket& lhs, int fd)
|
||||
{ return lhs.fd == fd; }
|
||||
|
||||
@@ -44,7 +44,7 @@ std::string http_methods_to_str(unsigned int methods);
|
||||
int path_is_valid(std::string path);
|
||||
void replace_all_substr(std::string &str, const std::string &ori_substr, const std::string &new_substr);
|
||||
std::string str_tolower(std::string str);
|
||||
void del_line_in_str(std::string * str, size_t pos, std::string delim);
|
||||
std::string extract_line(std::string * str, size_t pos, std::string delim);
|
||||
void throw_test();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -154,7 +154,8 @@ void Webserv::_check_script_status(Client *client, std::string output)
|
||||
client->status = atoi(output.c_str() + status_pos);
|
||||
::del_line_in_str(&output, pos, CRLF);
|
||||
}
|
||||
client->status = 200;
|
||||
else
|
||||
client->status = 200;
|
||||
}
|
||||
|
||||
void Webserv::_check_script_fields(Client *client, std::string output)
|
||||
@@ -165,8 +166,8 @@ void Webserv::_check_script_fields(Client *client, std::string output)
|
||||
std::map<std::string, std::string>::iterator it_scr;
|
||||
size_t pos;
|
||||
|
||||
srv_fld = parse_http_headers(client->response);
|
||||
scr_fld = parse_http_headers(output);
|
||||
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++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user