From 74c16f575efbf6deac13e2a87cdd4c94eedf29e0 Mon Sep 17 00:00:00 2001 From: Wilrik Date: Fri, 6 Jul 2018 16:36:06 +0200 Subject: [PATCH] fixed tcp_mem resource leak when sending 304 --- imageproxy.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imageproxy.go b/imageproxy.go index b61f730..a7fdc55 100644 --- a/imageproxy.go +++ b/imageproxy.go @@ -315,12 +315,13 @@ func (t *TransformingTransport) RoundTrip(req *http.Request) (*http.Response, er return nil, err } + defer resp.Body.Close() + if should304(req, resp) { // bare 304 response, full response will be used from cache return &http.Response{StatusCode: http.StatusNotModified}, nil } - defer resp.Body.Close() b, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err