File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ type Client struct {
3131// DefaultClientOptions read from the environment (SFC_NODES_BEARER_TOKEN,
3232// SFC_NODES_BASE_URL). This should be used to initialize new clients.
3333func DefaultClientOptions () []option.RequestOption {
34- defaults := []option.RequestOption {option .WithEnvironmentProduction ()}
34+ defaults := []option.RequestOption {option .WithHTTPClient ( defaultHTTPClient ()), option . WithEnvironmentProduction ()}
3535 if o , ok := os .LookupEnv ("SFC_NODES_BASE_URL" ); ok {
3636 defaults = append (defaults , option .WithBaseURL (o ))
3737 }
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 sfcnodes
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