fix(oohelperd): use throw-away HTTPClient, Dialer, Resolver (#833)
This diff modifies the implementation of oohelperd in the master branch to always use throw-away HTTPClient, Dialer, and Resolver. The rationale of this change is to ensure we're not hitting limits of the HTTPClient regarding the max number of connections per host. This issue is described at https://github.com/ooni/probe/issues/2182. While there, it feels more correct to use throw-away Dialer and Resolver. We have a different patch for the release/3.15 branch because of netx-related refactorings: https://github.com/ooni/probe-cli/pull/832.
This commit is contained in:
parent
59410edba9
commit
a4d17085f5
9 changed files with 87 additions and 60 deletions
|
|
@ -19,9 +19,9 @@ type CtrlHTTPResponse = webconnectivity.ControlHTTPRequestResult
|
|||
|
||||
// HTTPConfig configures the HTTP check.
|
||||
type HTTPConfig struct {
|
||||
Client model.HTTPClient
|
||||
Headers map[string][]string
|
||||
MaxAcceptableBody int64
|
||||
NewClient func() model.HTTPClient
|
||||
Out chan CtrlHTTPResponse
|
||||
URL string
|
||||
Wg *sync.WaitGroup
|
||||
|
|
@ -50,7 +50,9 @@ func HTTPDo(ctx context.Context, config *HTTPConfig) {
|
|||
}
|
||||
}
|
||||
}
|
||||
resp, err := config.Client.Do(req)
|
||||
clnt := config.NewClient()
|
||||
defer clnt.CloseIdleConnections()
|
||||
resp, err := clnt.Do(req)
|
||||
if err != nil {
|
||||
config.Out <- CtrlHTTPResponse{ // fix: emit -1 like old test helper does
|
||||
BodyLength: -1,
|
||||
|
|
|
|||
Loading…
Reference in a new issue