aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/http/transport.go
blob: cd6787ad3c66b523f4f0d5196f51b5c18ab62849 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package http

import (
	"net/http"
)

// transportOptions contains transport specific configuration.
type transportOptions struct {
	insecureSkipTLS bool
	// []byte is not comparable.
	caBundle string
}

func (c *client) addTransport(opts transportOptions, transport *http.Transport) {
	c.m.Lock()
	c.transports.Add(opts, transport)
	c.m.Unlock()
}

func (c *client) removeTransport(opts transportOptions) {
	c.m.Lock()
	c.transports.Remove(opts)
	c.m.Unlock()
}

func (c *client) fetchTransport(opts transportOptions) (*http.Transport, bool) {
	c.m.RLock()
	t, ok := c.transports.Get(opts)
	c.m.RUnlock()
	if !ok {
		return nil, false
	}
	transport, ok := t.(*http.Transport)
	if !ok {
		return nil, false
	}
	return transport, true
}