diff --git a/httpcache.go b/httpcache.go index b54f0ef..08ab457 100644 --- a/httpcache.go +++ b/httpcache.go @@ -8,6 +8,7 @@ package httpcache import ( "bufio" "bytes" + "context" "errors" "io" "io/ioutil" @@ -171,11 +172,10 @@ func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error if freshness == fresh { return cachedResp, nil } else if freshness == staleWhileRevalidate { - noCacheRequest := *req - noCacheRequest.Header = noCacheRequest.Header.Clone() + noCacheRequest := req.Clone(context.Background()) // Is this the right thing? noCacheRequest.Header.Set("cache-control", "no-cache") go func() { - resp, err := t.RoundTrip(&noCacheRequest) + resp, err := t.RoundTrip(noCacheRequest) if err == nil { defer resp.Body.Close() buffer := make([]byte, 4096)