mirror of
https://github.com/rancher/norman.git
synced 2025-09-05 17:20:20 +00:00
Make websocket dialer use same TLSClientConfig has http client
This commit is contained in:
@@ -25,7 +25,6 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
debug = false
|
debug = false
|
||||||
dialer = &websocket.Dialer{}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type APIBaseClientInterface interface {
|
type APIBaseClientInterface interface {
|
||||||
@@ -265,9 +264,15 @@ func NewAPIClient(opts *ClientOpts) (APIBaseClient, error) {
|
|||||||
result.Ops = &APIOperations{
|
result.Ops = &APIOperations{
|
||||||
Opts: opts,
|
Opts: opts,
|
||||||
Client: client,
|
Client: client,
|
||||||
|
Dialer: &websocket.Dialer{},
|
||||||
Types: result.Types,
|
Types: result.Types,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ht, ok := client.Transport.(*http.Transport)
|
||||||
|
if ok {
|
||||||
|
result.Ops.Dialer.TLSClientConfig = ht.TLSClientConfig
|
||||||
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +292,7 @@ func (a *APIBaseClient) Websocket(url string, headers map[string][]string) (*web
|
|||||||
httpHeaders.Add("Authorization", a.Opts.getAuthHeader())
|
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 {
|
func (a *APIBaseClient) List(schemaType string, opts *types.ListOpts, respObject interface{}) error {
|
||||||
|
@@ -8,6 +8,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rancher/norman/types"
|
"github.com/rancher/norman/types"
|
||||||
)
|
)
|
||||||
@@ -16,6 +17,7 @@ type APIOperations struct {
|
|||||||
Opts *ClientOpts
|
Opts *ClientOpts
|
||||||
Types map[string]types.Schema
|
Types map[string]types.Schema
|
||||||
Client *http.Client
|
Client *http.Client
|
||||||
|
Dialer *websocket.Dialer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) SetupRequest(req *http.Request) {
|
func (a *APIOperations) SetupRequest(req *http.Request) {
|
||||||
|
Reference in New Issue
Block a user