MCPcopy
hub / github.com/kagent-dev/kagent / BuildHTTPClient

Function BuildHTTPClient

go/adk/pkg/models/base.go:27–48  ·  view source on GitHub ↗

BuildHTTPClient creates an http.Client with the full transport stack: TLS → custom headers → timeout.

(tc TransportConfig)

Source from the content-addressed store, hash-verified

25// BuildHTTPClient creates an http.Client with the full transport stack:
26// TLS → custom headers → timeout.
27func BuildHTTPClient(tc TransportConfig) (*http.Client, error) {
28 transport, err := BuildTLSTransport(
29 http.DefaultTransport,
30 tc.TLSInsecureSkipVerify,
31 tc.TLSCACertPath,
32 tc.TLSDisableSystemCAs,
33 )
34 if err != nil {
35 return nil, err
36 }
37
38 if len(tc.Headers) > 0 {
39 transport = &headerTransport{base: transport, headers: tc.Headers}
40 }
41
42 timeout := defaultTimeout
43 if tc.Timeout != nil {
44 timeout = time.Duration(*tc.Timeout) * time.Second
45 }
46
47 return &http.Client{Timeout: timeout, Transport: transport}, nil
48}
49
50// BearerTokenKey is the context key for storing the bearer token for API key passthrough
51var BearerTokenKey = &contextKey{}

Calls 1

BuildTLSTransportFunction · 0.85