fix(all): introduce and use iox.CopyContext (#380)
* fix(all): introduce and use iox.CopyContext This PR is part of https://github.com/ooni/probe/issues/1417. In https://github.com/ooni/probe-cli/pull/379 we introduced a context aware wrapper for io.ReadAll (formerly ioutil.ReadAll). Here we introduce a context aware wrapper for io.Copy. * fix(humanize): more significant digits * fix: rename humanize files to follow the common pattern * fix aligment * fix test
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
@@ -13,6 +12,7 @@ import (
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
|
||||
"github.com/ooni/probe-cli/v3/internal/iox"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
|
||||
@@ -92,7 +92,7 @@ func (r Runner) httpGet(ctx context.Context, url string) error {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if _, err = io.Copy(ioutil.Discard, resp.Body); err != nil {
|
||||
if _, err = iox.CopyContext(ctx, ioutil.Discard, resp.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
// Implementation note: we shall check for this error once we have read the
|
||||
|
||||
Reference in New Issue
Block a user