Skip to content

Commit 3017dd2

Browse files
committed
chore: Log HTTP request details in multipart request
1 parent 9215b7c commit 3017dd2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

httpclient/multipartrequest.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,24 @@ func (c *Client) DoMultipartRequest(method, endpoint string, fields map[string]s
7070
}
7171

7272
// Initialize HeaderManager
73-
//log.Debug("Setting Authorization header with token", zap.String("Token", c.Token))
7473
headerHandler := headers.NewHeaderHandler(req, c.Logger, c.APIHandler, c.AuthTokenHandler)
7574

7675
// Use HeaderManager to set headers
77-
headerHandler.SetContentType(contentType)
76+
headerHandler.SetContentType(contentType) // Set correct content type with boundary
7877
headerHandler.SetRequestHeaders(endpoint)
7978
headerHandler.LogHeaders(c.clientConfig.ClientOptions.Logging.HideSensitiveData)
8079

80+
// Log request details
81+
const logSegmentSize = 1024 // 1 KB
82+
bodyLen := len(requestData)
83+
var logBody string
84+
if bodyLen <= 2*logSegmentSize {
85+
logBody = string(requestData)
86+
} else {
87+
logBody = string(requestData[:logSegmentSize]) + "..." + string(requestData[bodyLen-logSegmentSize:])
88+
}
89+
log.Debug("HTTP Request Details (partial body)", zap.String("Method", method), zap.String("URL", url), zap.String("Content-Type", contentType), zap.String("Body", logBody))
90+
8191
// Execute the request
8292
resp, err := c.httpClient.Do(req)
8393
if err != nil {

0 commit comments

Comments
 (0)