Merge pull request #16451 from hashicorp/jbardin/disco
add Transport field to Disco
This commit is contained in:
commit
f9ad58c66a
|
@ -39,6 +39,10 @@ var httpTransport = cleanhttp.DefaultPooledTransport() // overridden during test
|
||||||
type Disco struct {
|
type Disco struct {
|
||||||
hostCache map[svchost.Hostname]Host
|
hostCache map[svchost.Hostname]Host
|
||||||
credsSrc auth.CredentialsSource
|
credsSrc auth.CredentialsSource
|
||||||
|
|
||||||
|
// Transport is a custom http.Transport to use.
|
||||||
|
// A package default is used if this is nil.
|
||||||
|
Transport *http.Transport
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDisco() *Disco {
|
func NewDisco() *Disco {
|
||||||
|
@ -92,8 +96,14 @@ func (d *Disco) discover(host svchost.Hostname) Host {
|
||||||
Host: string(host),
|
Host: string(host),
|
||||||
Path: discoPath,
|
Path: discoPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t := d.Transport
|
||||||
|
if t == nil {
|
||||||
|
t = httpTransport
|
||||||
|
}
|
||||||
|
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Transport: httpTransport,
|
Transport: t,
|
||||||
Timeout: discoTimeout,
|
Timeout: discoTimeout,
|
||||||
|
|
||||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||||
|
|
Loading…
Reference in New Issue