From 4155695baf06d9a7dde1c8ddeba20e4a577716ff Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Fri, 18 Mar 2022 23:07:15 -0400 Subject: Document why `http2.Transport{}` is required. --- lbc/lbc.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lbc') diff --git a/lbc/lbc.go b/lbc/lbc.go index 5dd1214..50a4caa 100644 --- a/lbc/lbc.go +++ b/lbc/lbc.go @@ -85,6 +85,14 @@ func (lbd *LoadBearingConnectionDownload) Start( "Using an SSL Key Logger for this load-bearing download.\n", ) } + + // The presence of a custom TLSClientConfig in a *generic* `transport` + // means that go will default to HTTP/1.1 and cowardly avoid HTTP/2: + // https://github.com/golang/go/blob/7ca6902c171b336d98adbb103d701a013229c806/src/net/http/transport.go#L278 + // Also, it would appear that the API's choice of HTTP vs HTTP2 can + // depend on whether the url contains + // https:// or http://: + // https://github.com/golang/go/blob/7ca6902c171b336d98adbb103d701a013229c806/src/net/http/transport.go#L74 transport.TLSClientConfig = &tls.Config{ KeyLogWriter: lbd.KeyLogger, InsecureSkipVerify: true, @@ -181,6 +189,9 @@ func (lbu *LoadBearingConnectionUpload) Start( debug bool, ) bool { lbu.uploaded = 0 + + // See above for the rationale of doing http2.Transport{} here + // to ensure that we are using h2. transport := http2.Transport{} if !utilities.IsInterfaceNil(lbu.KeyLogger) { @@ -195,8 +206,6 @@ func (lbu *LoadBearingConnectionUpload) Start( } } - lbu.client = &http.Client{Transport: &transport} - lbu.client = &http.Client{Transport: &transport} lbu.debug = debug lbu.valid = true -- cgit v1.2.3