Skip to content

Commit

Permalink
updates to use net/http/httpproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
sharanyad committed Oct 6, 2021
1 parent 86ca4c9 commit c1d4a1c
Show file tree
Hide file tree
Showing 45 changed files with 73,848 additions and 2 deletions.
3 changes: 2 additions & 1 deletion agent/httpclient/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"time"

"github.com/aws/amazon-ecs-agent/agent/config"
"github.com/aws/amazon-ecs-agent/agent/utils"
"github.com/aws/amazon-ecs-agent/agent/utils/cipher"
"github.com/aws/amazon-ecs-agent/agent/version"
)
Expand Down Expand Up @@ -59,7 +60,7 @@ func New(timeout time.Duration, insecureSkipVerify bool) *http.Client {
// Note, these defaults are taken from the golang http library. We do not
// explicitly do not use theirs to avoid changing their behavior.
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
Proxy: utils.Proxy,
Dial: (&net.Dialer{
Timeout: defaultDialTimeout,
KeepAlive: defaultDialKeepalive,
Expand Down
8 changes: 8 additions & 0 deletions agent/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"io/ioutil"
"math"
"math/big"
"net/http"
"net/url"
"path/filepath"
"reflect"
"strconv"
Expand All @@ -32,6 +34,7 @@ import (
"github.com/aws/aws-sdk-go/aws/awserr"

"github.com/pkg/errors"
"golang.org/x/net/http/httpproxy"
)

func DefaultIfBlank(str string, default_value string) string {
Expand Down Expand Up @@ -234,3 +237,8 @@ func GetENIAttachmentId(eniAttachmentArn string) (string, error) {
}
return fields[len(fields)-1], nil
}

// Proxy is an uncached version of http.ProxyFromEnvironment.
func Proxy(req *http.Request) (*url.URL, error) {
return httpproxy.FromEnvironment().ProxyFunc()(req.URL)
}
Loading

0 comments on commit c1d4a1c

Please sign in to comment.