Skip to content

Commit

Permalink
Add a custom http client
Browse files Browse the repository at this point in the history
The use of a default client might not be enough to cancel long running
http requests. Enforcing a 10 second timeout in the http client will
ensure that the request is timed out even if the context doesn't have a
timer/cancel attached to it.
  • Loading branch information
ankur22 committed Feb 1, 2024
1 parent 39a52e8 commit 12ab6e9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions storage/file_persister.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (r *RemoteFilePersister) Persist(ctx context.Context, path string, data io.
return fmt.Errorf("creating upload request: %w", err)
}

resp, err := http.DefaultClient.Do(req)
resp, err := r.httpClient.Do(req)
if err != nil {
return fmt.Errorf("performing upload request: %w", err)
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func (r *RemoteFilePersister) getPreSignedURL(ctx context.Context, path string)
req.Header.Add(k, v)
}

resp, err := http.DefaultClient.Do(req)
resp, err := r.httpClient.Do(req)
if err != nil {
return "", fmt.Errorf("performing request: %w", err)
}
Expand Down

0 comments on commit 12ab6e9

Please sign in to comment.