File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ type Client struct {
4545// DefaultClientOptions read from the environment (GITPOD_API_KEY,
4646// GITPOD_BASE_URL). This should be used to initialize new clients.
4747func DefaultClientOptions () []option.RequestOption {
48- defaults := []option.RequestOption {option .WithEnvironmentProduction ()}
48+ defaults := []option.RequestOption {option .WithHTTPClient ( defaultHTTPClient ()), option . WithEnvironmentProduction ()}
4949 if o , ok := os .LookupEnv ("GITPOD_BASE_URL" ); ok {
5050 defaults = append (defaults , option .WithBaseURL (o ))
5151 }
Original file line number Diff line number Diff line change 1+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+ package gitpod
4+
5+ import (
6+ "net/http"
7+ "time"
8+ )
9+
10+ // defaultResponseHeaderTimeout bounds the time between a fully written request
11+ // and the server's response headers. It does not apply to the response body,
12+ // so long-running streams are unaffected. Without this, a server that accepts
13+ // the connection but never responds would hang the request indefinitely.
14+ const defaultResponseHeaderTimeout = 10 * time .Minute
15+
16+ // defaultHTTPClient returns an [*http.Client] used when the caller does not
17+ // supply one via [option.WithHTTPClient]. It clones [http.DefaultTransport]
18+ // and adds a [http.Transport.ResponseHeaderTimeout] so stuck connections
19+ // fail fast instead of compounding across retries.
20+ func defaultHTTPClient () * http.Client {
21+ transport := http .DefaultTransport .(* http.Transport ).Clone ()
22+ transport .ResponseHeaderTimeout = defaultResponseHeaderTimeout
23+ return & http.Client {Transport : transport }
24+ }
You can’t perform that action at this time.
0 commit comments