1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-04 08:45:22 +00:00

Make websocket dialer use same TLSClientConfig has http client

This commit is contained in:
Darren Shepherd
2018-06-19 11:18:04 -07:00
parent 875bcf4b2d
commit fbc49a97af
2 changed files with 9 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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) {