github.com/afxcn/moby@v1.13.1/client/transport.go (about)

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