MCPcopy
hub / github.com/cloudfoundry/cli / NewConnection

Function NewConnection

api/uaa/uaa_connection.go:23–45  ·  view source on GitHub ↗

NewConnection returns a pointer to a new UAA Connection

(skipSSLValidation bool, disableKeepAlives bool, dialTimeout time.Duration)

Source from the content-addressed store, hash-verified

21
22// NewConnection returns a pointer to a new UAA Connection
23func NewConnection(skipSSLValidation bool, disableKeepAlives bool, dialTimeout time.Duration) *UAAConnection {
24 tr := &http.Transport{
25 DialContext: (&net.Dialer{
26 KeepAlive: 30 * time.Second,
27 Timeout: dialTimeout,
28 }).DialContext,
29 DisableKeepAlives: disableKeepAlives,
30 Proxy: http.ProxyFromEnvironment,
31 TLSClientConfig: util.NewTLSConfig(nil, skipSSLValidation),
32 }
33
34 return &UAAConnection{
35 HTTPClient: &http.Client{
36 Transport: tr,
37 CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
38 // This prevents redirects. When making a request to /oauth/authorize,
39 // the client should not follow redirects in order to obtain the ssh
40 // passcode.
41 return http.ErrUseLastResponse
42 },
43 },
44 }
45}
46
47// Make takes a passedRequest, converts it into an HTTP request and then
48// executes it. The response is then injected into passedResponse.

Callers 2

NewClientFunction · 0.70

Calls 1

NewTLSConfigFunction · 0.92

Tested by

no test coverage detected