changed del_line_in_str to etract_line
This commit is contained in:
@@ -151,8 +151,12 @@ std::string str_tolower(std::string str)
|
|||||||
return 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)
|
||||||
{
|
{
|
||||||
|
std::string del_str;
|
||||||
size_t begin;
|
size_t begin;
|
||||||
size_t end;
|
size_t end;
|
||||||
|
|
||||||
@@ -168,10 +172,18 @@ void del_line_in_str(std::string * str, size_t pos, std::string delim)
|
|||||||
else
|
else
|
||||||
end += delim.size();
|
end += delim.size();
|
||||||
|
|
||||||
|
del_str = (*str).substr(begin, end - begin);
|
||||||
(*str).erase(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)
|
bool operator==(const listen_socket& lhs, int fd)
|
||||||
{ return lhs.fd == 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);
|
int path_is_valid(std::string path);
|
||||||
void replace_all_substr(std::string &str, const std::string &ori_substr, const std::string &new_substr);
|
void replace_all_substr(std::string &str, const std::string &ori_substr, const std::string &new_substr);
|
||||||
std::string str_tolower(std::string str);
|
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();
|
void throw_test();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ void Webserv::_check_script_status(Client *client, std::string output)
|
|||||||
client->status = atoi(output.c_str() + status_pos);
|
client->status = atoi(output.c_str() + status_pos);
|
||||||
::del_line_in_str(&output, pos, CRLF);
|
::del_line_in_str(&output, pos, CRLF);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
client->status = 200;
|
client->status = 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,8 +166,8 @@ void Webserv::_check_script_fields(Client *client, std::string output)
|
|||||||
std::map<std::string, std::string>::iterator it_scr;
|
std::map<std::string, std::string>::iterator it_scr;
|
||||||
size_t pos;
|
size_t pos;
|
||||||
|
|
||||||
srv_fld = parse_http_headers(client->response);
|
srv_fld = ::parse_http_headers(client->response);
|
||||||
scr_fld = parse_http_headers(output);
|
scr_fld = ::parse_http_headers(output);
|
||||||
// wip: compare both map to supress duplicates
|
// wip: compare both map to supress duplicates
|
||||||
for (it_srv = srv_fld.begin(); it_srv != srv_fld.end(); it_srv++)
|
for (it_srv = srv_fld.begin(); it_srv != srv_fld.end(); it_srv++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user