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.)
This commit is contained in:
Brad Fitzpatrick 2020-04-26 07:45:42 -07:00
parent 6fcbd4c4d4
commit eb6de2bd88

View File

@ -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,