|
6 | 6 | "fmt"
|
7 | 7 | "io/ioutil"
|
8 | 8 | "math/rand"
|
| 9 | + "net" |
| 10 | + "net/http" |
9 | 11 | "net/url"
|
10 | 12 | "strings"
|
11 | 13 | "time"
|
@@ -830,7 +832,25 @@ func awsConfigFromURL(awsURL *url.URL) (*aws.Config, error) {
|
830 | 832 | creds := credentials.NewStaticCredentials(awsURL.User.Username(), password, "")
|
831 | 833 | config := aws.NewConfig().
|
832 | 834 | WithCredentials(creds).
|
833 |
| - WithMaxRetries(0) // We do our own retries, so we can monitor them |
| 835 | + WithMaxRetries(0). // We do our own retries, so we can monitor them |
| 836 | + // Use a custom http.Client with the golang defaults but also specifying |
| 837 | + // MaxIdleConnsPerHost because of a bug in golang https://github.com/golang/go/issues/13801 |
| 838 | + // where MaxIdleConnsPerHost does not work as expected. |
| 839 | + WithHTTPClient(&http.Client{ |
| 840 | + Transport: &http.Transport{ |
| 841 | + Proxy: http.ProxyFromEnvironment, |
| 842 | + DialContext: (&net.Dialer{ |
| 843 | + Timeout: 30 * time.Second, |
| 844 | + KeepAlive: 30 * time.Second, |
| 845 | + DualStack: true, |
| 846 | + }).DialContext, |
| 847 | + MaxIdleConns: 100, |
| 848 | + IdleConnTimeout: 90 * time.Second, |
| 849 | + MaxIdleConnsPerHost: 100, |
| 850 | + TLSHandshakeTimeout: 3 * time.Second, |
| 851 | + ExpectContinueTimeout: 1 * time.Second, |
| 852 | + }, |
| 853 | + }) |
834 | 854 | if strings.Contains(awsURL.Host, ".") {
|
835 | 855 | return config.WithEndpoint(fmt.Sprintf("http://%s", awsURL.Host)).WithRegion("dummy"), nil
|
836 | 856 | }
|
|
0 commit comments