0
Fork 0
mirror of https://github.com/willnorris/imageproxy.git synced 2025-01-06 22:40:34 -05:00

include non-nil body in bare 304 response

This commit is contained in:
Will Norris 2017-06-17 12:45:15 -04:00
parent 038e10f436
commit 1fcd100d16

View file

@ -35,6 +35,8 @@ import (
tphttp "willnorris.com/go/imageproxy/third_party/http" tphttp "willnorris.com/go/imageproxy/third_party/http"
) )
var emptyBody io.ReadCloser = ioutil.NopCloser(new(bytes.Buffer))
// Proxy serves image requests. // Proxy serves image requests.
type Proxy struct { type Proxy struct {
Client *http.Client // client used to fetch remote URLs 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) { if should304(req, resp) {
// bare 304 response, full response will be used from cache // 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() defer resp.Body.Close()