mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Use one http response recorder per external http call (#16938)
This commit is contained in:
@@ -67,8 +67,12 @@ func getOpName(name string) (op string) {
|
||||
// otherwise, generate a trace event with request information but no response.
|
||||
func httpTracer(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// Setup a http request response recorder - this is needed for
|
||||
// http stats requests and audit if enabled.
|
||||
respRecorder := xhttp.NewResponseRecorder(w)
|
||||
|
||||
if globalTrace.NumSubscribers(madmin.TraceS3|madmin.TraceInternal) == 0 {
|
||||
h.ServeHTTP(w, r)
|
||||
h.ServeHTTP(respRecorder, r)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -80,9 +84,8 @@ func httpTracer(h http.Handler) http.Handler {
|
||||
ctx := context.WithValue(r.Context(), mcontext.ContextTraceKey, &tc)
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
// Setup a http request and response body recorder
|
||||
// Setup a http request body recorder
|
||||
reqRecorder := &xhttp.RequestRecorder{Reader: r.Body}
|
||||
respRecorder := xhttp.NewResponseRecorder(w)
|
||||
|
||||
tc.RequestRecorder = reqRecorder
|
||||
tc.ResponseRecorder = respRecorder
|
||||
|
||||
Reference in New Issue
Block a user