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
master
Harshavardhana 5 years ago committed by GitHub
parent f3022e891d
commit 4155f4e49b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      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)
}

Loading…
Cancel
Save