default and custom error pages response
+ refactoring in response.cpp (functions split) + added Client::clear() + added replace_all_substr() in utils.cpp
This commit is contained in:
@@ -84,3 +84,18 @@ std::string http_methods_to_str(unsigned int methods)
|
||||
|
||||
return (str);
|
||||
}
|
||||
|
||||
void replace_all_substr(std::string &str, const std::string &ori_substr, const std::string &new_substr)
|
||||
{
|
||||
if (ori_substr.empty())
|
||||
return;
|
||||
size_t pos = 0;
|
||||
while (1)
|
||||
{
|
||||
pos = str.find(ori_substr, pos);
|
||||
if (pos == std::string::npos)
|
||||
break;
|
||||
str.replace(pos, ori_substr.size(), new_substr);
|
||||
pos += new_substr.size();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user