diff --git a/clientbase/common.go b/clientbase/common.go index 83908e7b..ecaafb41 100644 --- a/clientbase/common.go +++ b/clientbase/common.go @@ -25,7 +25,6 @@ const ( var ( debug = false - dialer = &websocket.Dialer{} ) type APIBaseClientInterface interface { @@ -265,9 +264,15 @@ func NewAPIClient(opts *ClientOpts) (APIBaseClient, error) { result.Ops = &APIOperations{ Opts: opts, Client: client, + Dialer: &websocket.Dialer{}, Types: result.Types, } + ht, ok := client.Transport.(*http.Transport) + if ok { + result.Ops.Dialer.TLSClientConfig = ht.TLSClientConfig + } + return result, nil } @@ -287,7 +292,7 @@ func (a *APIBaseClient) Websocket(url string, headers map[string][]string) (*web httpHeaders.Add("Authorization", a.Opts.getAuthHeader()) } - return dialer.Dial(url, http.Header(httpHeaders)) + return a.Ops.Dialer.Dial(url, http.Header(httpHeaders)) } func (a *APIBaseClient) List(schemaType string, opts *types.ListOpts, respObject interface{}) error { diff --git a/clientbase/ops.go b/clientbase/ops.go index 474c14e6..2e7ce140 100644 --- a/clientbase/ops.go +++ b/clientbase/ops.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "net/http" + "github.com/gorilla/websocket" "github.com/pkg/errors" "github.com/rancher/norman/types" ) @@ -16,6 +17,7 @@ type APIOperations struct { Opts *ClientOpts Types map[string]types.Schema Client *http.Client + Dialer *websocket.Dialer } func (a *APIOperations) SetupRequest(req *http.Request) {