From 641a5ec998b9fe4bc30ec8a0fdca28cde8fcb7e8 Mon Sep 17 00:00:00 2001 From: JayT106 Date: Thu, 4 Nov 2021 12:38:08 -0400 Subject: [PATCH] rpc: fix inappropriate http request log (#7244) --- rpc/jsonrpc/server/http_uri_handler.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rpc/jsonrpc/server/http_uri_handler.go b/rpc/jsonrpc/server/http_uri_handler.go index 07b3616b4..9fb5c1cde 100644 --- a/rpc/jsonrpc/server/http_uri_handler.go +++ b/rpc/jsonrpc/server/http_uri_handler.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "net/http" + "net/http/httputil" "reflect" "regexp" "strings" @@ -36,7 +37,7 @@ func makeHTTPHandler(rpcFunc *RPCFunc, logger log.Logger) func(http.ResponseWrit // All other endpoints return func(w http.ResponseWriter, r *http.Request) { - logger.Debug("HTTP HANDLER", "req", r) + logger.Debug("HTTP HANDLER", "req", dumpHTTPRequest(r)) ctx := &rpctypes.Context{HTTPReq: r} args := []reflect.Value{reflect.ValueOf(ctx)} @@ -232,3 +233,12 @@ func getParam(r *http.Request, param string) string { } return s } + +func dumpHTTPRequest(r *http.Request) string { + d, e := httputil.DumpRequest(r, true) + if e != nil { + return e.Error() + } + + return string(d) +}