diff --git a/httpclient/multipartrequest.go b/httpclient/multipartrequest.go index 6a73a15..1e6701c 100644 --- a/httpclient/multipartrequest.go +++ b/httpclient/multipartrequest.go @@ -63,7 +63,7 @@ func (c *Client) DoMultiPartRequest(method, endpoint string, files map[string][] } // Log the constructed request body for debugging - logRequestBody(body, log) + logMultiPartRequestBody(body, log) // Construct the full URL for the API endpoint. url := c.APIHandler.ConstructAPIResourceEndpoint(endpoint, log) @@ -84,9 +84,6 @@ func (c *Client) DoMultiPartRequest(method, endpoint string, files map[string][] headerHandler.SetRequestHeaders(endpoint) headerHandler.LogHeaders(c.clientConfig.ClientOptions.Logging.HideSensitiveData) - // Log headers for debugging - logHeaders(req, log) - req = req.WithContext(ctx) startTime := time.Now() @@ -269,8 +266,8 @@ func logUploadProgress(totalSize int64, log logger.Logger) func(int64) { } } -// logRequestBody logs the constructed request body for debugging purposes. -func logRequestBody(body *bytes.Buffer, log logger.Logger) { +// logMultiPartRequestBody logs the constructed request body for debugging purposes. +func logMultiPartRequestBody(body *bytes.Buffer, log logger.Logger) { bodyBytes := body.Bytes() bodyStr := string(bodyBytes) @@ -292,11 +289,12 @@ func logRequestBody(body *bytes.Buffer, log logger.Logger) { continue // Skip the last boundary marker or empty parts } if strings.Contains(part, "Content-Disposition: form-data; name=\"file\"") { - // If it's a file part, only log the headers + // If it's a file part, log headers and indicate content is omitted headersEndIndex := strings.Index(part, "\r\n\r\n") if headersEndIndex != -1 { headers := part[:headersEndIndex] - loggedParts = append(loggedParts, headers+"\r\n\r\n\r\n") + fileMeta := part[headersEndIndex+4 : len(part)-2] // Extract the file metadata portion + loggedParts = append(loggedParts, headers+"\r\n\r\n\r\n"+fileMeta) } else { loggedParts = append(loggedParts, part) } @@ -311,12 +309,3 @@ func logRequestBody(body *bytes.Buffer, log logger.Logger) { log.Info("Request body preview", zap.String("body", loggedBody)) } - -// logHeaders logs the request headers for debugging purposes. -func logHeaders(req *http.Request, log logger.Logger) { - for key, values := range req.Header { - for _, value := range values { - log.Info("Request header", zap.String("key", key), zap.String("value", value)) - } - } -}