Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit cbc6a8a

Browse files
committed
Detach asynchronous request from current context
1 parent 4621264 commit cbc6a8a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

httpcache.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package httpcache
88
import (
99
"bufio"
1010
"bytes"
11+
"context"
1112
"errors"
1213
"io"
1314
"io/ioutil"
@@ -171,11 +172,10 @@ func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error
171172
if freshness == fresh {
172173
return cachedResp, nil
173174
} else if freshness == staleWhileRevalidate {
174-
noCacheRequest := *req
175-
noCacheRequest.Header = noCacheRequest.Header.Clone()
175+
noCacheRequest := req.Clone(context.Background()) // Is this the right thing?
176176
noCacheRequest.Header.Set("cache-control", "no-cache")
177177
go func() {
178-
resp, err := t.RoundTrip(&noCacheRequest)
178+
resp, err := t.RoundTrip(noCacheRequest)
179179
if err == nil {
180180
defer resp.Body.Close()
181181
buffer := make([]byte, 4096)

0 commit comments

Comments
 (0)