From eb6de2bd88d49855a1016e2c3f07ae26e7f850d7 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 26 Apr 2020 07:45:42 -0700 Subject: [PATCH] control/controlclient: restore Options.HTTPC as Options.HTTPTestClient I removed the HTTPC field in b6fa5a69bef but it was apparently still used in [oss-skipped] tests. Restore it, but name it so it's more obvious that it's only for tests. (It currently is, and I'd like to keep it like that for now.) --- control/controlclient/direct.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index 3eb2bca0c..5a83e3067 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -102,6 +102,7 @@ type Options struct { NewDecompressor func() (Decompressor, error) KeepAlive bool Logf logger.Logf + HTTPTestClient *http.Client // optional HTTP client to use (for tests only) } type Decompressor interface { @@ -128,10 +129,13 @@ func NewDirect(opts Options) (*Direct, error) { opts.Logf = log.Printf } - tr := http.DefaultTransport.(*http.Transport).Clone() - tr.ForceAttemptHTTP2 = true - tr.TLSClientConfig = tlsdial.Config(serverURL.Host, tr.TLSClientConfig) - httpc := &http.Client{Transport: tr} + httpc := opts.HTTPTestClient + if httpc == nil { + tr := http.DefaultTransport.(*http.Transport).Clone() + tr.ForceAttemptHTTP2 = true + tr.TLSClientConfig = tlsdial.Config(serverURL.Host, tr.TLSClientConfig) + httpc = &http.Client{Transport: tr} + } c := &Direct{ httpc: httpc,