diff --git a/net/http/inc/THttpCallArg.h b/net/http/inc/THttpCallArg.h index 53530b7f4dad0f077462e306abee647cbbe982ae..b3cec087a66efa3baf3f657e3f488b9f16670cec 100644 --- a/net/http/inc/THttpCallArg.h +++ b/net/http/inc/THttpCallArg.h @@ -61,6 +61,8 @@ protected: TString CountHeader(const TString &buf, Int_t number = -1111) const; + void ReplaceAllinContent(const std::string &from, const std::string &to, bool once = false); + private: std::shared_ptr<THttpWSEngine> fWSEngine; ///<! web-socket engine, which supplied to run created web socket @@ -70,8 +72,6 @@ private: void AssignWSId(); std::shared_ptr<THttpWSEngine> TakeWSEngine(); - void ReplaceAllinContent(const std::string &from, const std::string &to); - /** Method used to modify content of web page used by web socket handler */ virtual void CheckWSPageContent(THttpWSHandler *) {} diff --git a/net/http/src/THttpCallArg.cxx b/net/http/src/THttpCallArg.cxx index 194d070c2471b4ef7852843563a3bbf20536a44b..f4d68dfa0c60a9f4f8e2590b78bd397b723f8208 100644 --- a/net/http/src/THttpCallArg.cxx +++ b/net/http/src/THttpCallArg.cxx @@ -257,11 +257,12 @@ std::shared_ptr<THttpWSEngine> THttpCallArg::TakeWSEngine() /// Replace all occurrences of \param from by \param to in content /// Used only internally -void THttpCallArg::ReplaceAllinContent(const std::string &from, const std::string &to) +void THttpCallArg::ReplaceAllinContent(const std::string &from, const std::string &to, bool once) { std::size_t start_pos = 0; while((start_pos = fContent.find(from, start_pos)) != std::string::npos) { fContent.replace(start_pos, from.length(), to); + if (once) return; start_pos += to.length(); // Handles case where 'to' is a substring of 'from' } }