diff options
-rw-r--r-- | content/context/google/google.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/content/context/google/google.go b/content/context/google/google.go index 75442d0..e25cfc1 100644 --- a/content/context/google/google.go +++ b/content/context/google/google.go @@ -81,13 +81,11 @@ func Search(ctx context.Context, query string) (Results, error) { // for f to exit, and returns ctx.Err. Otherwise, httpDo returns f's error. func httpDo(ctx context.Context, req *http.Request, f func(*http.Response, error) error) error { // Run the HTTP request in a goroutine and pass the response to f. - tr := &http.Transport{} - client := &http.Client{Transport: tr} c := make(chan error, 1) - go func() { c <- f(client.Do(req)) }() + req = req.WithContext(ctx) + go func() { c <- f(http.DefaultClient.Do(req)) }() select { case <-ctx.Done(): - tr.CancelRequest(req) <-c // Wait for f to return. return ctx.Err() case err := <-c: |