Restore the ability to use a proxy for all HTTP requests

The default transport was changed in commit 0d66f2c and the proxy feature was forgotten.

- https://golang.org/src/net/http/transport.go#L43
- https://golang.org/pkg/net/http/#ProxyFromEnvironment
This commit is contained in:
Lee Tang 2020-10-31 10:03:41 +08:00 committed by GitHub
parent d70b4d39ab
commit 46c13b5185
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -268,6 +268,7 @@ func (c *Client) buildRequest(method string, body io.Reader) (*http.Request, err
func (c *Client) buildClient() http.Client {
client := http.Client{Timeout: time.Duration(c.ClientTimeout) * time.Second}
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
// Default is 30s.
Timeout: 10 * time.Second,