Skip to content

Commit

Permalink
implementing reasonable timeouts in the http clients we use
Browse files Browse the repository at this point in the history
Signed-off-by: greg pereira <[email protected]>
  • Loading branch information
Gregory-Pereira committed Apr 29, 2024
1 parent 753273d commit c37c8ca
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 @@ -779,6 +779,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 @@ -971,7 +974,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 c37c8ca

Please sign in to comment.