Skip to content

Commit

Permalink
fix(chore): Content-Length set before store
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweak committed Aug 17, 2023
1 parent bca1957 commit 60f2d29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ func (s *SouinBaseHandler) Store(
if res.Header.Get("Date") == "" {
res.Header.Set("Date", now.Format(http.TimeFormat))
}
if res.Header.Get("Content-Length") == "" {
res.Header.Set("Content-Length", fmt.Sprint(customWriter.Buf.Len()))
}
res.Header.Set(rfc.StoredLengthHeader, res.Header.Get("Content-Length"))
response, err := httputil.DumpResponse(&res, true)
if err == nil {
Expand Down
1 change: 0 additions & 1 deletion plugins/caddy/httpcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func TestHead(t *testing.T) {
localhost:9080 {
route /cache-head {
cache
header Content-Length 12
respond "Hello, HEAD!"
}
}`, "caddyfile")
Expand Down

0 comments on commit 60f2d29

Please sign in to comment.