Browse Source

Update httpcache to fix memory leak

pull/156/head
Kegan Dougal 8 years ago
parent
commit
ca451098b2
  1. 2
      vendor/manifest
  2. 12
      vendor/src/github.com/gregjones/httpcache/httpcache.go
  3. 5
      vendor/src/github.com/gregjones/httpcache/httpcache_test.go

2
vendor/manifest

@ -126,7 +126,7 @@
{
"importpath": "github.com/gregjones/httpcache",
"repository": "https://github.com/gregjones/httpcache",
"revision": "413781778738c08fdbb98e1dd65f5abffe8832d0",
"revision": "d02018f006d98f58512bf3adfc171d88d17626df",
"branch": "master"
},
{

12
vendor/src/github.com/gregjones/httpcache/httpcache.go

@ -223,22 +223,22 @@ func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error
}
if req2 != nil {
// Associate original request with cloned request so we can refer to
// it in CancelRequest()
// it in CancelRequest(). Release the mapping when it's no longer needed.
t.setModReq(req, req2)
req = req2
defer func() {
defer func(originalReq *http.Request) {
// Release req/clone mapping on error
if err != nil {
t.setModReq(req, nil)
t.setModReq(originalReq, nil)
}
if resp != nil {
// Release req/clone mapping on body close/EOF
resp.Body = &onEOFReader{
rc: resp.Body,
fn: func() { t.setModReq(req, nil) },
fn: func() { t.setModReq(originalReq, nil) },
}
}
}()
}(req)
req = req2
}
}
}

5
vendor/src/github.com/gregjones/httpcache/httpcache_test.go

@ -465,6 +465,11 @@ func TestGetWithLastModified(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer func() {
if len(s.transport.modReq) != 0 {
t.Errorf("Request-map is not empty")
}
}()
{
resp, err := s.client.Do(req)
if err != nil {

Loading…
Cancel
Save