Debian Codegraph @

plumbing/transport/http/transport.go

raw
1 package http
2
3 import (
4 "net/http"
5 "net/url"
6 )
7
8 // transportOptions contains transport specific configuration.
9 type transportOptions struct {
10 insecureSkipTLS bool
11 // []byte is not comparable.
12 clientCert string
13 clientKey string
14 caBundle string
15 proxyURL url.URL
16 }
17
18 func (c *client) addTransport(opts transportOptions, transport *http.Transport) {
19 c.mutex.Lock()
20 c.transports.Add(opts, transport)
21 c.mutex.Unlock()
22 }
23
24 func (c *client) removeTransport(opts transportOptions) {
25 c.mutex.Lock()
26 c.transports.Remove(opts)
27 c.mutex.Unlock()
28 }
29
30 func (c *client) fetchTransport(opts transportOptions) (*http.Transport, bool) {
31 c.mutex.RLock()
32 t, ok := c.transports.Get(opts)
33 c.mutex.RUnlock()
34 if !ok {
35 return nil, false
36 }
37 transport, ok := t.(*http.Transport)
38 if !ok {
39 return nil, false
40 }
41 return transport, true
42 }