Skip to content

Commit

Permalink
disable log application/octet-stream (#4997)
Browse files Browse the repository at this point in the history
  • Loading branch information
Googlom authored Jul 26, 2024
1 parent 5861661 commit 8c79fce
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,13 @@ func (t *TransportWrapper) logRequest(req *http.Request) {
log.Entry().Debugf("--> %v request to %v", req.Method, req.URL)
log.Entry().Debugf("headers: %v", transformHeaders(req.Header))
log.Entry().Debugf("cookies: %v", transformCookies(req.Cookies()))
if t.doLogRequestBodyOnDebug && req.Body != nil {
if t.doLogRequestBodyOnDebug && req.Header.Get("Content-Type") == "application/octet-stream" {
// skip logging byte content as it's useless
} else if t.doLogRequestBodyOnDebug && req.Body != nil {
var buf bytes.Buffer
tee := io.TeeReader(req.Body, &buf)
log.Entry().Debugf("body: %v", transformBody(tee))
req.Body = io.NopCloser(bytes.NewReader(buf.Bytes()))
log.Entry().Debugf("body: %v", transformBody(tee))
}
log.Entry().Debug("--------------------------------")
}
Expand Down

0 comments on commit 8c79fce

Please sign in to comment.