566c6b246a
This diff addresses another point of https://github.com/ooni/probe/issues/1956: > - [ ] observe that we're still using a bunch of private interfaces for common interfaces such as the `Dialer`, so we can get rid of these private interfaces and always use the ones in `model`, which allows us to remove a bunch of legacy wrappers Additional cleanups may still be possible. The more I cleanup, the more I see there's extra legacy code we can dispose of (which seems good?).
31 lines
1.0 KiB
Go
31 lines
1.0 KiB
Go
package httptransport
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
|
)
|
|
|
|
// NewSystemTransport creates a new "system" HTTP transport. That is a transport
|
|
// using the Go standard library with custom dialer and TLS dialer.
|
|
//
|
|
// Deprecation warning
|
|
//
|
|
// New code should use netxlite.NewHTTPTransport instead.
|
|
func NewSystemTransport(config Config) model.HTTPTransport {
|
|
txp := http.DefaultTransport.(*http.Transport).Clone()
|
|
txp.DialContext = config.Dialer.DialContext
|
|
txp.DialTLSContext = config.TLSDialer.DialTLSContext
|
|
// Better for Cloudflare DNS and also better because we have less
|
|
// noisy events and we can better understand what happened.
|
|
txp.MaxConnsPerHost = 1
|
|
// The following (1) reduces the number of headers that Go will
|
|
// automatically send for us and (2) ensures that we always receive
|
|
// back the true headers, such as Content-Length. This change is
|
|
// functional to OONI's goal of observing the network.
|
|
txp.DisableCompression = true
|
|
return txp
|
|
}
|
|
|
|
var _ model.HTTPTransport = &http.Transport{}
|