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

Function forceURLTransport

coderd/workspaceapps/apptest/setup.go:605–616  ·  view source on GitHub ↗

forceURLTransport forces the client to route all requests to the client's configured URLs host regardless of hostname.

(t *testing.T, client *codersdk.Client)

Source from the content-addressed store, hash-verified

603// forceURLTransport forces the client to route all requests to the client's
604// configured URLs host regardless of hostname.
605func forceURLTransport(t *testing.T, client *codersdk.Client) {
606 defaultTransport, ok := http.DefaultTransport.(*http.Transport)
607 require.True(t, ok)
608 transport := defaultTransport.Clone()
609 transport.DialContext = func(ctx context.Context, network, _ string) (net.Conn, error) {
610 return (&net.Dialer{}).DialContext(ctx, network, client.URL.Host)
611 }
612 client.HTTPClient.Transport = transport
613 t.Cleanup(func() {
614 transport.CloseIdleConnections()
615 })
616}

Callers 3

AppClientMethod · 0.85
RunFunction · 0.85

Calls 4

DialContextMethod · 0.65
CleanupMethod · 0.65
CloseIdleConnectionsMethod · 0.65
CloneMethod · 0.45

Tested by

no test coverage detected