rpc: fix inappropriate http request log (#7244)

This commit is contained in:
JayT106
2021-11-04 12:38:08 -04:00
committed by GitHub
parent b3b1279d1f
commit 641a5ec998

View File

@@ -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)
}