diff --git a/maxutils/maxbase/src/http.cc b/maxutils/maxbase/src/http.cc index b8783a15e..6deec2f72 100644 --- a/maxutils/maxbase/src/http.cc +++ b/maxutils/maxbase/src/http.cc @@ -15,6 +15,7 @@ #include #include #include +#include using std::map; using std::string; @@ -22,27 +23,6 @@ using std::string; namespace { -// TODO: Remove once trim is in maxbase. -// trim from beginning (in place) -inline void ltrim(std::string &s) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { - return !std::isspace(ch); - })); -} - -// trim from end (in place) -inline void rtrim(std::string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { - return !std::isspace(ch); - }).base(), s.end()); -} - -// trim from both ends (in place) -inline void trim(std::string &s) { - ltrim(s); - rtrim(s); -} - template inline void checked_curl_setopt(CURL* pCurl, CURLoption option, T value) { @@ -84,8 +64,8 @@ size_t header_callback(char* ptr, size_t size, size_t nmemb, void* userdata) string key(ptr, i - ptr); ++i; string value(i, end - i); - trim(key); - trim(value); + mxb::trim(key); + mxb::trim(value); pHeaders->insert(std::make_pair(key, value)); } }