Skip to content

Commit

Permalink
Merge pull request #312 from Gregory-Pereira/228-reasonable-http-time…
Browse files Browse the repository at this point in the history
…outs

implementing reasonable timeouts in the http clients
  • Loading branch information
nerdalert authored Apr 29, 2024
2 parents 62bf0e0 + c37c8ca commit 5dc6b18
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion worker/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,9 @@ func (w *Worker) fetchModelName(fullName bool) (string, error) {
endpoint += "models"

http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
http.DefaultTransport.(*http.Transport).TLSHandshakeTimeout = 10 * time.Second
http.DefaultTransport.(*http.Transport).ResponseHeaderTimeout = 10 * time.Second
http.DefaultTransport.(*http.Transport).ExpectContinueTimeout = 1 * time.Second

req, err := http.NewRequestWithContext(w.ctx, "GET", endpoint, nil)
if err != nil {
Expand Down Expand Up @@ -992,7 +995,12 @@ func (w *Worker) createTLSHttpClient() (*http.Client, error) {
InsecureSkipVerify: true,
}
httpClient := &http.Client{
Transport: &http.Transport{TLSClientConfig: tlsConfig},
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
TLSHandshakeTimeout: 10 * time.Second,
ResponseHeaderTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
},
}
return httpClient, nil
}
Expand Down

0 comments on commit 5dc6b18

Please sign in to comment.