Skip to content
Snippets Groups Projects
Commit 2b25bade authored by Sergey Linev's avatar Sergey Linev
Browse files

http: move THttpCallArg::ReplaceAllinContent method to protected area

Will be used in different plugins to modify delivered web page
parent 2a37bbb3
No related branches found
No related tags found
No related merge requests found
...@@ -61,6 +61,8 @@ protected: ...@@ -61,6 +61,8 @@ protected:
TString CountHeader(const TString &buf, Int_t number = -1111) const; TString CountHeader(const TString &buf, Int_t number = -1111) const;
void ReplaceAllinContent(const std::string &from, const std::string &to, bool once = false);
private: private:
std::shared_ptr<THttpWSEngine> fWSEngine; ///<! web-socket engine, which supplied to run created web socket std::shared_ptr<THttpWSEngine> fWSEngine; ///<! web-socket engine, which supplied to run created web socket
...@@ -70,8 +72,6 @@ private: ...@@ -70,8 +72,6 @@ private:
void AssignWSId(); void AssignWSId();
std::shared_ptr<THttpWSEngine> TakeWSEngine(); 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 */ /** Method used to modify content of web page used by web socket handler */
virtual void CheckWSPageContent(THttpWSHandler *) {} virtual void CheckWSPageContent(THttpWSHandler *) {}
......
...@@ -257,11 +257,12 @@ std::shared_ptr<THttpWSEngine> THttpCallArg::TakeWSEngine() ...@@ -257,11 +257,12 @@ std::shared_ptr<THttpWSEngine> THttpCallArg::TakeWSEngine()
/// Replace all occurrences of \param from by \param to in content /// Replace all occurrences of \param from by \param to in content
/// Used only internally /// 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; std::size_t start_pos = 0;
while((start_pos = fContent.find(from, start_pos)) != std::string::npos) { while((start_pos = fContent.find(from, start_pos)) != std::string::npos) {
fContent.replace(start_pos, from.length(), to); fContent.replace(start_pos, from.length(), to);
if (once) return;
start_pos += to.length(); // Handles case where 'to' is a substring of 'from' start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment