summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/httpcache
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-10-15 14:07:10 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-10-15 14:07:10 -0600
commitabf5ab340ed76792214ae80c62df7abe0ad1b8a8 (patch)
treef0cedd8a36fb03a2ad324c9398180aafb8bd462a /modules/caddyhttp/httpcache
parentacf7dea68fe6ace110221faa26c2503a1ea432ce (diff)
caddyhttp: Improve ResponseRecorder to buffer headers
Diffstat (limited to 'modules/caddyhttp/httpcache')
-rw-r--r--modules/caddyhttp/httpcache/httpcache.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/modules/caddyhttp/httpcache/httpcache.go b/modules/caddyhttp/httpcache/httpcache.go
index 1b2cfd2..0b49c7e 100644
--- a/modules/caddyhttp/httpcache/httpcache.go
+++ b/modules/caddyhttp/httpcache/httpcache.go
@@ -130,8 +130,7 @@ func (c *Cache) getter(ctx groupcache.Context, key string, dest groupcache.Sink)
// we need to record the response if we are to cache it; only cache if
// request is successful (TODO: there's probably much more nuance needed here)
- var rr caddyhttp.ResponseRecorder
- rr = caddyhttp.NewResponseRecorder(combo.rw, buf, func(status int) bool {
+ rr := caddyhttp.NewResponseRecorder(combo.rw, buf, func(status int, header http.Header) bool {
shouldBuf := status < 300
if shouldBuf {
@@ -141,7 +140,7 @@ func (c *Cache) getter(ctx groupcache.Context, key string, dest groupcache.Sink)
// the rest will be the body, which will be written
// implicitly for us by the recorder
err := gob.NewEncoder(buf).Encode(headerAndStatus{
- Header: rr.Header(),
+ Header: header,
Status: status,
})
if err != nil {