diff --git a/gui/webdisplay/cef/base_handler.cxx b/gui/webdisplay/cef/base_handler.cxx
index d3c30ed5b0faa6d58c72975059b15f147719e589..8cf9bb541fb275548c8f921e7a35fea432ad0b57 100644
--- a/gui/webdisplay/cef/base_handler.cxx
+++ b/gui/webdisplay/cef/base_handler.cxx
@@ -157,7 +157,7 @@ public:
       if (message == "connect") {
          TCefWSEngine *ws = new TCefWSEngine(callback);
          arg->SetMethod("WS_CONNECT");
-         arg->SetWSHandle(ws);
+         ws->AttachTo(*arg);
          arg->SetWSId(ws->GetId());
          printf("Create CEF WS engine with id %u\n", ws->GetId());
       } else {
diff --git a/net/http/inc/THttpCallArg.h b/net/http/inc/THttpCallArg.h
index eb93414a48f631476c2a7f1683d3511b6eeeb309..1d8f206b15eeb6d4545769f2aabe8106f47302bc 100644
--- a/net/http/inc/THttpCallArg.h
+++ b/net/http/inc/THttpCallArg.h
@@ -20,12 +20,14 @@
 
 class THttpServer;
 class THttpWSEngine;
+class THttpWSHandler;
 
 class THttpCallArg : public TObject {
-
-protected:
    friend class THttpServer;
+   friend class THttpWSEngine;
+   friend class THttpWSHandler;
 
+protected:
    TString fTopName;  ///<! top item name
    TString fMethod;   ///<! request method like GET or POST
    TString fPathName; ///<! item path
@@ -36,8 +38,7 @@ protected:
    void *fPostData;        ///<! binary data received with post request
    Long_t fPostDataLength; ///<! length of binary data
 
-   THttpWSEngine *fWSHandle; ///<!  web-socket engine, which helps to run it
-   UInt_t fWSId;             ///<! websocket identifier, used in web-socket related operations
+   UInt_t fWSId; ///<! websocket identifier, used in web-socket related operations
 
    std::condition_variable fCond; ///<! condition used to wait for processing
 
@@ -58,6 +59,12 @@ protected:
 
    TString CountHeader(const TString &buf, Int_t number = -1111) const;
 
+private:
+   THttpWSEngine *fWSEngine; ///<!  web-socket engine, which helps to run it
+
+   void SetWSEngine(THttpWSEngine *);
+   THttpWSEngine *TakeWSEngine();
+
 public:
    THttpCallArg();
    ~THttpCallArg();
@@ -86,10 +93,6 @@ public:
 
    void SetPostData(void *data, Long_t length, Bool_t make_copy = kFALSE);
 
-   void SetWSHandle(THttpWSEngine *handle);
-
-   THttpWSEngine *TakeWSHandle();
-
    /** set web-socket id */
    void SetWSId(UInt_t id) { fWSId = id; }
 
diff --git a/net/http/inc/THttpWSEngine.h b/net/http/inc/THttpWSEngine.h
index fb0eba135c9f117fb77db0602cf0d7953dd5dd0b..255bc5d1e9816357218562da71f603ac33db91d8 100644
--- a/net/http/inc/THttpWSEngine.h
+++ b/net/http/inc/THttpWSEngine.h
@@ -24,6 +24,8 @@ protected:
 public:
    virtual ~THttpWSEngine() {}
 
+   void AttachTo(THttpCallArg &);
+
    virtual UInt_t GetId() const = 0;
 
    virtual void ClearHandle() = 0;
diff --git a/net/http/src/TCivetweb.cxx b/net/http/src/TCivetweb.cxx
index 0165a649221bf6258a7d175a493a4102e07dfeab..97ede49132b33d6f756c1042167395b4b48c20bb 100644
--- a/net/http/src/TCivetweb.cxx
+++ b/net/http/src/TCivetweb.cxx
@@ -93,8 +93,10 @@ void websocket_ready_handler(struct mg_connection *conn, void *)
    arg.SetQuery(request_info->query_string);        // query arguments
    arg.SetMethod("WS_READY");
 
+
    arg.SetWSId(TString::Hash((void *)&conn, sizeof(void *)));
-   arg.SetWSHandle(new TCivetwebWSEngine(conn));
+   auto ws = new TCivetwebWSEngine(conn);
+   ws->AttachTo(arg);
 
    serv->ExecuteHttp(&arg);
 }
diff --git a/net/http/src/THttpCallArg.cxx b/net/http/src/THttpCallArg.cxx
index 71b5f26b5638e8b02a75f6c7c6eaf83c1a696482..5bf2381a1a8dca48c8f3d9d00d5e65257b1df49e 100644
--- a/net/http/src/THttpCallArg.cxx
+++ b/net/http/src/THttpCallArg.cxx
@@ -30,9 +30,9 @@ ClassImp(THttpCallArg);
 /// constructor
 
 THttpCallArg::THttpCallArg()
-   : TObject(), fTopName(), fMethod(), fPathName(), fFileName(), fUserName(), fQuery(), fPostData(0),
-     fPostDataLength(0), fWSHandle(nullptr), fWSId(0), fContentType(), fRequestHeader(), fHeader(), fContent(), fZipping(0),
-     fBinData(0), fBinDataLength(0), fNotifyFlag(kFALSE)
+   : TObject(), fTopName(), fMethod(), fPathName(), fFileName(), fUserName(), fQuery(), fPostData(nullptr),
+     fPostDataLength(0), fWSId(0), fContentType(), fRequestHeader(), fHeader(), fContent(), fZipping(0),
+     fBinData(nullptr), fBinDataLength(0), fNotifyFlag(kFALSE), fWSEngine(nullptr)
 {
 }
 
@@ -46,9 +46,9 @@ THttpCallArg::~THttpCallArg()
       fPostData = nullptr;
    }
 
-   if (fWSHandle) {
-      delete fWSHandle;
-      fWSHandle = nullptr;
+   if (fWSEngine) {
+      delete fWSEngine;
+      fWSEngine = nullptr;
    }
 
    if (fBinData) {
@@ -89,9 +89,11 @@ TString THttpCallArg::AccessHeader(TString &buf, const char *name, const char *v
       }
 
       curr += strlen(name);
-      while ((curr < next) && (buf[curr] != ':')) curr++;
+      while ((curr < next) && (buf[curr] != ':'))
+         curr++;
       curr++;
-      while ((curr < next) && (buf[curr] == ' ')) curr++;
+      while ((curr < next) && (buf[curr] == ' '))
+         curr++;
 
       if (value == 0)
          return buf(curr, next - curr);
@@ -123,7 +125,8 @@ TString THttpCallArg::CountHeader(const TString &buf, Int_t number) const
       if (cnt == number) {
          // we should extract name of header
          Int_t separ = curr + 1;
-         while ((separ < next) && (buf[separ] != ':')) separ++;
+         while ((separ < next) && (buf[separ] != ':'))
+            separ++;
          return buf(curr, separ - curr);
       }
 
@@ -170,21 +173,21 @@ void THttpCallArg::SetPostData(void *data, Long_t length, Bool_t make_copy)
 ////////////////////////////////////////////////////////////////////////////////
 /// assign websocket handle with HTTP call
 
-void THttpCallArg::SetWSHandle(THttpWSEngine *handle)
+void THttpCallArg::SetWSEngine(THttpWSEngine *engine)
 {
-   if (fWSHandle)
-      delete fWSHandle;
-   fWSHandle = handle;
+   if (fWSEngine)
+      delete fWSEngine;
+   fWSEngine = engine;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 /// takeout websocket handle with HTTP call
 /// can be done only once
 
-THttpWSEngine *THttpCallArg::TakeWSHandle()
+THttpWSEngine *THttpCallArg::TakeWSEngine()
 {
-   THttpWSEngine *res = fWSHandle;
-   fWSHandle = nullptr;
+   THttpWSEngine *res = fWSEngine;
+   fWSEngine = nullptr;
    return res;
 }
 
@@ -220,7 +223,8 @@ void THttpCallArg::SetPathAndFileName(const char *fullpath)
    if (rslash == 0) {
       fFileName = fullpath;
    } else {
-      while ((fullpath != rslash) && (*fullpath == '/')) fullpath++;
+      while ((fullpath != rslash) && (*fullpath == '/'))
+         fullpath++;
       fPathName.Append(fullpath, rslash - fullpath);
       if (fPathName == "/")
          fPathName.Clear();
diff --git a/net/http/src/THttpServer.cxx b/net/http/src/THttpServer.cxx
index 4c325ff27b2464052cf3ad7886563c74750fe5cc..fa970f0a6c3b3ba72881bf17af706327f1bec870 100644
--- a/net/http/src/THttpServer.cxx
+++ b/net/http/src/THttpServer.cxx
@@ -833,7 +833,7 @@ void THttpServer::ProcessRequest(THttpCallArg *arg)
 
          if (handler->HandleWS(arg)) {
             arg->SetMethod("WS_READY");
-            arg->SetWSHandle(handle);
+            handle->AttachTo(*arg);
 
             if (handler->HandleWS(arg)) {
                arg->SetContent(TString::Format("%u", arg->GetWSId()));
@@ -880,7 +880,7 @@ void THttpServer::ProcessRequest(THttpCallArg *arg)
 
       if (!handler || !handler->HandleWS(arg))
          arg->Set404();
-      if (!arg->Is404() && (arg->fMethod == "WS_CONNECT") && arg->fWSHandle) {
+      if (!arg->Is404() && (arg->fMethod == "WS_CONNECT") && arg->fWSEngine) {
          arg->SetMethod("WS_READY");
          if (handler->HandleWS(arg)) {
             arg->SetContent(TString::Format("%u", arg->GetWSId()));
diff --git a/net/http/src/THttpWSEngine.cxx b/net/http/src/THttpWSEngine.cxx
index 2da1115dd50a86e5de80d87876a309c89dda71f6..28eba44f609deb71e3d20d6f68fd3462f34c0128 100644
--- a/net/http/src/THttpWSEngine.cxx
+++ b/net/http/src/THttpWSEngine.cxx
@@ -11,6 +11,8 @@
 
 #include "THttpWSEngine.h"
 
+#include "THttpCallArg.h"
+
 //////////////////////////////////////////////////////////////////////////
 //                                                                      //
 // THttpWSEngine                                                        //
@@ -20,6 +22,15 @@
 //                                                                      //
 //////////////////////////////////////////////////////////////////////////
 
+
+////////////////////////////////////////////////////////////////////////////////
+/// Attach WSEngine to THttpCallArg to transport to the WSHandler
+
+void THttpWSEngine::AttachTo(THttpCallArg &arg)
+{
+   arg.SetWSEngine(this);
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 /// Envelope for sending string via the websocket
 
diff --git a/net/http/src/THttpWSHandler.cxx b/net/http/src/THttpWSHandler.cxx
index 0703d1cea8dcc2f44f2f719114614793f8f583bb..776af0c1acd043a1fab85b1680663e99b769a1c8 100644
--- a/net/http/src/THttpWSHandler.cxx
+++ b/net/http/src/THttpWSHandler.cxx
@@ -145,7 +145,7 @@ Bool_t THttpWSHandler::HandleWS(THttpCallArg *arg)
          RemoveEngine(engine);
       }
 
-      engine = arg->TakeWSHandle();
+      engine = arg->TakeWSEngine();
 
       fEngines.push_back(engine);