diff --git a/jsonrpc/handler.go b/jsonrpc/handler.go index cd78075f37..e738700e0e 100644 --- a/jsonrpc/handler.go +++ b/jsonrpc/handler.go @@ -156,15 +156,16 @@ func (h *Handler) Handle(req handleRequest) types.Response { } // HandleWs handle websocket requests -func (h *Handler) HandleWs(reqBody []byte, wsConn *websocket.Conn) ([]byte, error) { +func (h *Handler) HandleWs(reqBody []byte, wsConn *websocket.Conn, httpReq *http.Request) ([]byte, error) { var req types.Request if err := json.Unmarshal(reqBody, &req); err != nil { return types.NewResponse(req, nil, types.NewRPCError(types.InvalidRequestErrorCode, "Invalid json request")).Bytes() } handleReq := handleRequest{ - Request: req, - wsConn: wsConn, + Request: req, + wsConn: wsConn, + HttpRequest: httpReq, } return h.Handle(handleReq).Bytes() diff --git a/jsonrpc/server.go b/jsonrpc/server.go index 8d28ded549..bbfe5f0639 100644 --- a/jsonrpc/server.go +++ b/jsonrpc/server.go @@ -366,7 +366,7 @@ func (s *Server) handleWs(w http.ResponseWriter, req *http.Request) { go func() { mu.Lock() defer mu.Unlock() - resp, err := s.handler.HandleWs(message, wsConn) + resp, err := s.handler.HandleWs(message, wsConn, req) if err != nil { log.Error(fmt.Sprintf("Unable to handle WS request, %s", err.Error())) _ = wsConn.WriteMessage(msgType, []byte(fmt.Sprintf("WS Handle error: %s", err.Error())))