common: use HTTP proxy if available from env [GH-252]

This commit is contained in:
Mitchell Hashimoto 2013-08-18 12:34:36 -06:00
parent b998e88b0a
commit 8bbed8656a
2 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,9 @@
## 0.3.3 (unreleased)
IMPROVEMENTS:
* core: All HTTP downloads across Packer now support the standard
proxy environmental variables (`HTTP_PROXY`, `NO_PROXY`, etc.) [GH-252]
## 0.3.2 (August 18, 2013)

View File

@ -188,7 +188,18 @@ func (*HTTPDownloader) Cancel() {
func (d *HTTPDownloader) Download(dst io.Writer, src *url.URL) error {
log.Printf("Starting download: %s", src.String())
resp, err := http.Get(src.String())
req, err := http.NewRequest("GET", src.String(), nil)
if err != nil {
return err
}
httpClient := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
},
}
resp, err := httpClient.Do(req)
if err != nil {
return err
}