1//go:build integration && perftest 2// +build integration,perftest 3 4package downloader 5 6import ( 7 "net" 8 "net/http" 9 "time" 10 11 "github.com/aws/aws-sdk-go-v2/aws" 12 awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http" 13) 14 15func NewHTTPClient(cfg ClientConfig) aws.HTTPClient { 16 return awshttp.NewBuildableClient().WithTransportOptions(func(tr *http.Transport) { 17 *tr = http.Transport{ 18 Proxy: http.ProxyFromEnvironment, 19 DialContext: (&net.Dialer{ 20 Timeout: cfg.Timeouts.Connect, 21 KeepAlive: 30 * time.Second, 22 }).DialContext, 23 MaxIdleConns: cfg.MaxIdleConns, 24 MaxIdleConnsPerHost: cfg.MaxIdleConnsPerHost, 25 IdleConnTimeout: 90 * time.Second, 26 27 DisableKeepAlives: !cfg.KeepAlive, 28 TLSHandshakeTimeout: cfg.Timeouts.TLSHandshake, 29 ExpectContinueTimeout: cfg.Timeouts.ExpectContinue, 30 ResponseHeaderTimeout: cfg.Timeouts.ResponseHeader, 31 32 ReadBufferSize: cfg.ReadBufferSize, 33 WriteBufferSize: cfg.WriteBufferSize, 34 } 35 }) 36} 37