Skip to content

Commit

Permalink
feat: do not use default http client on download with progress
Browse files Browse the repository at this point in the history
  • Loading branch information
juev committed Dec 10, 2023
1 parent 62a1eb0 commit 8fb3b9e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion utils/utils.go
Expand Up @@ -3,9 +3,11 @@ package utils
import (
"fmt"
"io"
"net"
"net/http"
"os"
"path"
"time"

"github.com/gookit/color"
"github.com/schollz/progressbar/v3"
Expand All @@ -17,7 +19,17 @@ func DownloadWithProgress(url string, tarName string, destFolder string) (err er
if err != nil {
return err
}
resp, err := http.DefaultClient.Do(req)
client := &http.Client{
Transport: &http.Transport{
Dial: (&net.Dialer{
Timeout: 5 * time.Second,
}).Dial,
TLSHandshakeTimeout: 5 * time.Second,
},
Timeout: 10 * time.Second,
}

resp, err := client.Do(req)
if err != nil {
return err
}
Expand Down

0 comments on commit 8fb3b9e

Please sign in to comment.