From 2b25badeb3f6d354827ff980c78bb457f748707d Mon Sep 17 00:00:00 2001 From: Sergey Linev <S.Linev@gsi.de> Date: Tue, 19 Mar 2019 10:34:34 +0100 Subject: [PATCH] http: move THttpCallArg::ReplaceAllinContent method to protected area Will be used in different plugins to modify delivered web page --- net/http/inc/THttpCallArg.h | 4 ++-- net/http/src/THttpCallArg.cxx | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/net/http/inc/THttpCallArg.h b/net/http/inc/THttpCallArg.h index 53530b7f4da..b3cec087a66 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 194d070c247..f4d68dfa0c6 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' } } -- GitLab