MCPcopy
hub / github.com/moby/moby / WithHTTPClient

Function WithHTTPClient

client/client_options.go:161–177  ·  view source on GitHub ↗

WithHTTPClient overrides the client's HTTP client with the specified one.

(client *http.Client)

Source from the content-addressed store, hash-verified

159
160// WithHTTPClient overrides the client's HTTP client with the specified one.
161func WithHTTPClient(client *http.Client) Opt {
162 return func(c *clientConfig) error {
163 if client != nil {
164 // Make a clone of client so modifications do not affect
165 // the caller's client. Clone here instead of in New()
166 // as other options (WithHost) also mutate c.client.
167 // Cloned clients share the same CookieJar as the
168 // original.
169 hc := *client
170 if ht, ok := hc.Transport.(*http.Transport); ok {
171 hc.Transport = ht.Clone()
172 }
173 c.client = &hc
174 }
175 return nil
176 }
177}
178
179// WithTimeout configures the time limit for requests made by the HTTP client.
180func WithTimeout(timeout time.Duration) Opt {

Callers 5

TestWithHTTPClientFunction · 0.85
TestResponseErrorsFunction · 0.85
WithMockClientFunction · 0.85
WithBaseMockClientFunction · 0.85
TestTLSCloseWriterFunction · 0.85

Calls 1

CloneMethod · 0.45

Tested by 5

TestWithHTTPClientFunction · 0.68
TestResponseErrorsFunction · 0.68
WithMockClientFunction · 0.68
WithBaseMockClientFunction · 0.68
TestTLSCloseWriterFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…