Skip to content

Commit

Permalink
download: Add proxy support
Browse files Browse the repository at this point in the history
Our use of cavaliercoder/grab relies on the http_proxy/https_proxy
environment variables to make use of proxies.
This has been causing issues in the past (see 'proxy: Use our own http
transport with crc's proxy config'), and this is also not enough when
a proxy accessed over https is used, and usage of proxy-ca-file is
needed.

This commit makes use of the recently introduced network.HTTPTransport()
to solve this.
  • Loading branch information
cfergeau authored and praveenkumar committed Sep 24, 2021
1 parent b50dc99 commit 7f59773
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ package download
import (
"os"

"github.com/cavaliercoder/grab"
"github.com/code-ready/crc/pkg/crc/logging"
"github.com/code-ready/crc/pkg/crc/network"

"github.com/cavaliercoder/grab"
"github.com/pkg/errors"
)

func Download(uri, destination string, mode os.FileMode) (string, error) {
logging.Debugf("Downloading %s to %s", uri, destination)

client := grab.NewClient()
client.HTTPClient.Transport = network.HTTPTransport()
req, err := grab.NewRequest(destination, uri)
if err != nil {
return "", errors.Wrapf(err, "unable to get response from %s", uri)
Expand Down

0 comments on commit 7f59773

Please sign in to comment.