Tizen_4.0 base
[platform/upstream/docker-engine.git] / client / transport.go
1 package client
2
3 import (
4         "crypto/tls"
5         "net/http"
6 )
7
8 // transportFunc allows us to inject a mock transport for testing. We define it
9 // here so we can detect the tlsconfig and return nil for only this type.
10 type transportFunc func(*http.Request) (*http.Response, error)
11
12 func (tf transportFunc) RoundTrip(req *http.Request) (*http.Response, error) {
13         return tf(req)
14 }
15
16 // resolveTLSConfig attempts to resolve the TLS configuration from the
17 // RoundTripper.
18 func resolveTLSConfig(transport http.RoundTripper) *tls.Config {
19         switch tr := transport.(type) {
20         case *http.Transport:
21                 return tr.TLSClientConfig
22         default:
23                 return nil
24         }
25 }