本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/transport.DebugWrappers函数的典型用法代码示例。如果您正苦于以下问题:Golang DebugWrappers函数的具体用法?Golang DebugWrappers怎么用?Golang DebugWrappers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DebugWrappers函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Dial
// Dial opens a connection to a remote server and attempts to negotiate a SPDY
// connection. Upon success, it returns the connection and the protocol
// selected by the server.
func (e *streamExecutor) Dial(protocols ...string) (httpstream.Connection, string, error) {
rt := transport.DebugWrappers(e.transport)
// TODO the client probably shouldn't be created here, as it doesn't allow
// flexibility to allow callers to configure it.
client := &http.Client{Transport: rt}
req, err := http.NewRequest(e.method, e.url.String(), nil)
if err != nil {
return nil, "", fmt.Errorf("error creating request: %v", err)
}
for i := range protocols {
req.Header.Add(httpstream.HeaderProtocolVersion, protocols[i])
}
resp, err := client.Do(req)
if err != nil {
return nil, "", fmt.Errorf("error sending request: %v", err)
}
defer resp.Body.Close()
conn, err := e.upgrader.NewConnection(resp)
if err != nil {
return nil, "", err
}
return conn, resp.Header.Get(httpstream.HeaderProtocolVersion), nil
}
示例2: clientForUser
func clientForUser(user string) *http.Client {
return &http.Client{
Transport: transport.NewBearerAuthRoundTripper(
user,
transport.DebugWrappers(http.DefaultTransport),
),
}
}
示例3: newConnection
// newConnection creates a new connection
func newConnection(url url.URL, dialTimeout time.Duration, allowInsecure, enableV2 bool) *connection {
var isV2 *bool
if !enableV2 {
v2 := false
isV2 = &v2
}
var rt http.RoundTripper
if allowInsecure {
rt = knet.SetTransportDefaults(&http.Transport{
Dial: (&net.Dialer{
Timeout: dialTimeout,
KeepAlive: 30 * time.Second,
}).Dial,
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
})
} else {
rt = knet.SetTransportDefaults(&http.Transport{
Dial: (&net.Dialer{
Timeout: dialTimeout,
KeepAlive: 30 * time.Second,
}).Dial,
})
}
rt = transport.DebugWrappers(rt)
jar, _ := cookiejar.New(nil)
client := &http.Client{Jar: jar, Transport: rt}
return &connection{
url: url,
client: client,
cached: make(map[string]repository),
isV2: isV2,
allowInsecure: allowInsecure,
}
}