From 1fcd100d163a083b22509ca2a42d8efe9b3df34c Mon Sep 17 00:00:00 2001 From: Will Norris Date: Sat, 17 Jun 2017 12:45:15 -0400 Subject: [PATCH] include non-nil body in bare 304 response --- imageproxy.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imageproxy.go b/imageproxy.go index c18840c..cf84818 100644 --- a/imageproxy.go +++ b/imageproxy.go @@ -35,6 +35,8 @@ import ( tphttp "willnorris.com/go/imageproxy/third_party/http" ) +var emptyBody io.ReadCloser = ioutil.NopCloser(new(bytes.Buffer)) + // Proxy serves image requests. type Proxy struct { Client *http.Client // client used to fetch remote URLs @@ -305,7 +307,7 @@ func (t *TransformingTransport) RoundTrip(req *http.Request) (*http.Response, er if should304(req, resp) { // bare 304 response, full response will be used from cache - return &http.Response{StatusCode: http.StatusNotModified}, nil + return &http.Response{StatusCode: http.StatusNotModified, Body: emptyBody}, nil } defer resp.Body.Close()