Skip to content

Commit

Permalink
Merge pull request #215 from deploymenttheory/v0.1.50-dev
Browse files Browse the repository at this point in the history
chore: troubleshooting context
  • Loading branch information
ShocOne authored Jun 5, 2024
2 parents 0bd079c + a937cd2 commit b6400d6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions httpclient/multipartrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package httpclient

import (
"bytes"
"context"
"encoding/base64"
"fmt"
"io"
Expand Down Expand Up @@ -58,8 +59,12 @@ func (c *Client) DoMultiPartRequest(method, endpoint string, files map[string][]
// Construct the full URL for the API endpoint.
url := c.APIHandler.ConstructAPIResourceEndpoint(endpoint, log)

// Create the HTTP request
req, err := http.NewRequest(method, url, body)
// Create a context with timeout
ctx, cancel := context.WithTimeout(context.Background(), c.clientConfig.ClientOptions.Timeout.CustomTimeout.Duration())
defer cancel()

// Create the HTTP request with context
req, err := http.NewRequestWithContext(ctx, method, url, body)
if err != nil {
log.Error("Failed to create HTTP request", zap.Error(err))
return nil, err
Expand Down Expand Up @@ -286,8 +291,6 @@ func logMultiPartRequestBody(body *bytes.Buffer, log logger.Logger) {
encoding := "none"
if strings.Contains(headers, "base64") || strings.Contains(bodyContent, "base64,") {
encoding = "base64"
} else if strings.Contains(headers, "quoted-printable") {
encoding = "quoted-printable"
}

// Log headers and indicate content is omitted
Expand Down

0 comments on commit b6400d6

Please sign in to comment.