1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-16 05:16:08 +02:00

disable log application/octet-stream (#4997)

This commit is contained in:
Googlom 2024-07-26 13:26:26 +05:00 committed by GitHub
parent 58616619bd
commit 8c79fcee36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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("--------------------------------")
}