Browse Source

rpc: fix inappropriate http request log (#7244)

pull/7245/head
JayT106 3 years ago
committed by GitHub
parent
commit
641a5ec998
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions
  1. +11
    -1
      rpc/jsonrpc/server/http_uri_handler.go

+ 11
- 1
rpc/jsonrpc/server/http_uri_handler.go View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"net/http" "net/http"
"net/http/httputil"
"reflect" "reflect"
"regexp" "regexp"
"strings" "strings"
@ -36,7 +37,7 @@ func makeHTTPHandler(rpcFunc *RPCFunc, logger log.Logger) func(http.ResponseWrit
// All other endpoints // All other endpoints
return func(w http.ResponseWriter, r *http.Request) { 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} ctx := &rpctypes.Context{HTTPReq: r}
args := []reflect.Value{reflect.ValueOf(ctx)} args := []reflect.Value{reflect.ValueOf(ctx)}
@ -232,3 +233,12 @@ func getParam(r *http.Request, param string) string {
} }
return s return s
} }
func dumpHTTPRequest(r *http.Request) string {
d, e := httputil.DumpRequest(r, true)
if e != nil {
return e.Error()
}
return string(d)
}

Loading…
Cancel
Save