MCPcopy Index your code
hub / github.com/coder/coder / newHTTPTransport

Function newHTTPTransport

cli/root.go:845–862  ·  view source on GitHub ↗
(tlsConfig *tls.Config)

Source from the content-addressed store, hash-verified

843}
844
845func newHTTPTransport(tlsConfig *tls.Config) (http.RoundTripper, error) {
846 defaultTransport, ok := http.DefaultTransport.(*http.Transport)
847 if !ok {
848 if tlsConfig != nil {
849 return nil, xerrors.New("cannot apply TLS config: http.DefaultTransport is not *http.Transport")
850 }
851 return http.DefaultTransport, nil
852 }
853
854 // Clone http.DefaultTransport for each CLI client. Parallel tests and
855 // embedded callers may close idle connections on their own clients, and
856 // sharing the process-global transport can interrupt in-flight requests.
857 transport := defaultTransport.Clone()
858 if tlsConfig != nil {
859 transport.TLSClientConfig = tlsConfig
860 }
861 return transport, nil
862}
863
864func (r *RootCmd) createUnauthenticatedClient(ctx context.Context, serverURL *url.URL, inv *serpent.Invocation) (*codersdk.Client, error) {
865 // Load TLS config for login and other unauthenticated requests

Calls 2

NewMethod · 0.65
CloneMethod · 0.45