Skip to content

Commit

Permalink
Allow users to specify a custom http transport implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
vansante committed Jan 17, 2019
1 parent 304dc29 commit 007d102
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion download.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Options struct {
RetryWaitMultiplier float64
FileMode os.FileMode
BufferSize int
HTTPTransport http.RoundTripper
Logger Logger
}

Expand Down Expand Up @@ -224,7 +225,8 @@ func retryWait(options *Options) {
// doDownloadRequest sends an actual download request and returns the content length (again) and response body reader
func doDownloadRequest(ctx context.Context, url string, downloadFrom, totalContentLength int64, options *Options) (body io.ReadCloser, err error) {
client := http.Client{
Timeout: options.Timeout,
Timeout: options.Timeout,
Transport: options.HTTPTransport,
}

// See: https://stackoverflow.com/a/29200933/3536354
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.2.2
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 // indirect
golang.org/x/tools v0.0.0-20181218204010-d4971274fe38 // indirect
golang.org/x/tools v0.0.0-20190116231616-b258f6da2383 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 h1:rJm0LuqUjoDhSk2zO9ISMSTo
golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/tools v0.0.0-20181218204010-d4971274fe38 h1:e07OqjPO5oqQAJqid1fAwyMi/IK+hfSYrivMpzzAJtU=
golang.org/x/tools v0.0.0-20181218204010-d4971274fe38/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190116231616-b258f6da2383 h1:CWP4O+Q3OaGBOLxV1/YRnzRSpvZYJlauwRUu3auRH5s=
golang.org/x/tools v0.0.0-20190116231616-b258f6da2383/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

0 comments on commit 007d102

Please sign in to comment.