From 4155f4e49be95ccf3281f2bcd43086f33360936d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 27 Sep 2019 10:19:27 -0700 Subject: [PATCH] trace: Print either Transfer-Encoding or Content-Length (#8314) If Transfer-Encoding is set client would have never set Content-Length as its considered malformed HTTP request --- cmd/http-tracer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/http-tracer.go b/cmd/http-tracer.go index d6424252c..be22e6748 100644 --- a/cmd/http-tracer.go +++ b/cmd/http-tracer.go @@ -100,8 +100,10 @@ func Trace(f http.HandlerFunc, logBody bool, w http.ResponseWriter, r *http.Requ // Setup a http request body recorder reqHeaders := r.Header.Clone() - reqHeaders.Set("Content-Length", strconv.Itoa(int(r.ContentLength))) reqHeaders.Set("Host", r.Host) + if len(r.TransferEncoding) == 0 { + reqHeaders.Set("Content-Length", strconv.Itoa(int(r.ContentLength))) + } for _, enc := range r.TransferEncoding { reqHeaders.Add("Transfer-Encoding", enc) }