NewConnection returns a pointer to a new UAA Connection
(skipSSLValidation bool, disableKeepAlives bool, dialTimeout time.Duration)
| 21 | |
| 22 | // NewConnection returns a pointer to a new UAA Connection |
| 23 | func 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. |
no test coverage detected