control/controlclient: restore Options.HTTPC as Options.HTTPTestClient
I removed the HTTPC field in 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.)
@@ -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
}
+ 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}
+ httpc = &http.Client{Transport: tr}
+ }
c := &Direct{
httpc: httpc,
