// EnsureTransporterFinalized will ensure that when the HTTP client is GCed
// the runtime will close the idle connections (so that they won't leak)
// this function was adopted from Hashicorp's go-cleanhttp package
551219
func EnsureTransporterFinalized(httpTransport *http.Transport) {
	runtime.SetFinalizer(&httpTransport, func(transportInt **http.Transport) {
		(*transportInt).CloseIdleConnections()
	})
}
33418
func HTTP2Transporter(config *tls.Config) Transporter {
	if config == nil {
		config = &tls.Config{InsecureSkipVerify: true}
	}
	return &http2Transporter{
		clients:   make(map[string]*http.Client),
		tlsConfig: config,
	}
}
983178
func contextTransport(ctx context.Context) http.RoundTripper {
	if client, ok := ctx.Value(HTTPClient).(*http.Client); ok {
		return client.Transport
	}
	return nil
}
1007756
func (pc *ProxyConfig) InstallInDefaultTransport() error {
	transport, ok := http.DefaultTransport.(*http.Transport)
	if !ok {
		return errors.Errorf("http.DefaultTransport was %T instead of *http.Transport", http.DefaultTransport)
	}
	transport.Proxy = pc.GetProxy
	return nil
}
1254655
func (fw *Framework) NewTransportForSecureReply(reply protocol.SecureReply) (message protocol.TransportMessage, err error) {
	switch reply.Version() {
	case protocol.SecureReplyV1:
		message, err = v1.NewTransportMessage(fw.Config.Identity)
		message.SetReplyData(reply)
	default:
		err = fmt.Errorf("Do not know how to create a Transport message for SecureRequest version %s", reply.Version())
	}

	return
}
1309395
func (c *Collector) WithTransport(transport http.RoundTripper) {
	c.backend.Client.Transport = transport
}
1221362
func (s *Server) newHTTP2Transport(c net.Conn, authInfo credentials.AuthInfo) transport.ServerTransport {
	config := &transport.ServerConfig{
		MaxStreams:            s.opts.maxConcurrentStreams,
		AuthInfo:              authInfo,
		InTapHandle:           s.opts.inTapHandle,
		StatsHandler:          s.opts.statsHandler,
		KeepaliveParams:       s.opts.keepaliveParams,
		KeepalivePolicy:       s.opts.keepalivePolicy,
		InitialWindowSize:     s.opts.initialWindowSize,
		InitialConnWindowSize: s.opts.initialConnWindowSize,
		WriteBufferSize:       s.opts.writeBufferSize,
		ReadBufferSize:        s.opts.readBufferSize,
		ChannelzParentID:      s.channelzID,
		MaxHeaderListSize:     s.opts.maxHeaderListSize,
	}
	st, err := transport.NewServerTransport("http2", c, config)
	if err != nil {
		s.mu.Lock()
		s.errorf("NewServerTransport(%q) failed: %v", c.RemoteAddr(), err)
		s.mu.Unlock()
		c.Close()
		grpclog.Warningln("grpc: Server.Serve failed to create ServerTransport: ", err)
		return nil
	}

	return st
}
1105118
func HandlerFinalizer(f ...HandlerFinalizerFunc) HandlerOption {
	return func(h *Handler) { h.finalizer = append(h.finalizer, f...) }
}
675615
func ServerFinalizer(f httptransport.ServerFinalizerFunc) ServerOption {
	return func(s *Server) { s.finalizer = f }
}
1220574
func ResolveCacheImporterFunc(sm *session.Manager, resolverOpt resolver.ResolveOptionsFunc, rs reference.Store, is imagestore.Store) remotecache.ResolveCacheImporterFunc {

	upstream := registryremotecache.ResolveCacheImporterFunc(sm, resolverOpt)

	return func(ctx context.Context, attrs map[string]string) (remotecache.Importer, specs.Descriptor, error) {
		if dt, err := tryImportLocal(rs, is, attrs["ref"]); err == nil {
			return newLocalImporter(dt), specs.Descriptor{}, nil
		}
		return upstream(ctx, attrs)
	}
}
809660
func (cli *OpsGenieClient) makeHTTPTransportSettings() {
	if cli.httpTransportSettings != nil {
		if cli.httpTransportSettings.MaxRetryAttempts <= 0 {
			cli.httpTransportSettings.MaxRetryAttempts = defaultMaxRetryAttempts
		}
		if cli.httpTransportSettings.ConnectionTimeout <= 0 {
			cli.httpTransportSettings.ConnectionTimeout = defaultConnectionTimeout
		}
		if cli.httpTransportSettings.RequestTimeout <= 0 {
			cli.httpTransportSettings.RequestTimeout = defaultRequestTimeout
		}
	} else {
		cli.httpTransportSettings = &HTTPTransportSettings{MaxRetryAttempts: defaultMaxRetryAttempts, ConnectionTimeout: defaultConnectionTimeout, RequestTimeout: defaultRequestTimeout}
	}
}
650915
func NewRetryTransport(retrier *retry.Retrier, transport RoundTripper) *RetryTransport {
	return &RetryTransport{
		Retrier: retrier,
		MethodsToRetry: map[string]bool{
			"":     true, // http.Client treats empty methods the same as "GET"
			"GET":  true,
			"HEAD": true,
		},
		Transport: transport,
	}
}
424706
func CreateHTTPTransport(caBundle *x509.CertPool, hostname string) *http.Transport {
	return &http.Transport{TLSClientConfig: &tls.Config{
		ServerName: hostname,
		RootCAs:    caBundle,
	}}
}
919426
func ResolveCacheExporterFunc(sm *session.Manager) remotecache.ResolveCacheExporterFunc {
	return func(ctx context.Context, attrs map[string]string) (remotecache.Exporter, error) {
		store := attrs[attrDest]
		if store == "" {
			return nil, errors.New("local cache exporter requires dest")
		}
		csID := contentStoreIDPrefix + store
		cs, err := getContentStore(ctx, sm, csID)
		if err != nil {
			return nil, err
		}
		return remotecache.NewExporter(cs), nil
	}
}
304547
func (s *Server) EnableSinglePort() {
	s.singlePort = true
	s.handlers = make(map[string]chan []byte, datagramLength)
	s.gcCollect = make(chan string)
	s.bufPool = sync.Pool{
		New: func() interface{} {
			return make([]byte, datagramLength)
		},
	}
	go s.internalGC()
}
1159113
func BuildGCEMetadatTransporter(serviceAccount string) (GoogleOAuthClient, error) {
	client := &http.Client{
		Transport: &oauth2.Transport{

			Source: googleOauth2.ComputeTokenSource(""),
		},
	}

	return &gOAuthClient{
		httpclient: client,
	}, nil
}
418206
func (kt *SharedKeybaseTransport) Finalize() {
	kt.mutex.Lock()
	defer kt.mutex.Unlock()
	kt.transport = kt.stagedTransport
	kt.stagedTransport = nil
}