Skip to content

Commit

Permalink
fix missing http client transport issue when loading CACerts from goc…
Browse files Browse the repository at this point in the history
…ertifi (fixes Alpine issue)
  • Loading branch information
danenania committed Nov 8, 2018
1 parent b096f21 commit 79ff5d3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"net"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -138,7 +139,15 @@ func UrlWithLoggingParams(baseUrl string, options FetchOptions) string {

func InitHttpClient(timeoutSeconds float64) {
to := time.Second * time.Duration(timeoutSeconds)
Client = &http.Client{Timeout: to}
Client = &http.Client{
Timeout: to,
Transport: &http.Transport{
Dial: (&net.Dialer{
Timeout: time.Duration(timeoutSeconds/2) * time.Second,
}).Dial,
TLSHandshakeTimeout: time.Duration(timeoutSeconds/2) * time.Second,
},
}
}

func httpExecRequest(
Expand Down Expand Up @@ -206,8 +215,7 @@ func logRequestIfVerbose(url string, options FetchOptions, err error, r *http.Re
fmt.Fprintln(os.Stderr, err)
} else if r.StatusCode >= 500 {
fmt.Fprintf(os.Stderr, "Loading from %s failed.\n", url)
fmt.Fprintln(os.Stderr, "Response status:")
fmt.Fprintln(os.Stderr, string(r.StatusCode))
fmt.Fprintf(os.Stderr, "Response status: %s\n", strconv.Itoa(r.StatusCode))
} else {
fmt.Fprintf(os.Stderr, "Loaded from %s successfully.\n", url)
}
Expand Down

0 comments on commit 79ff5d3

Please sign in to comment.