edge: a short page body is never published
TestPageShortBodyIsNotStored guards the recorder's Content-Length check: a marked page whose app stops mid-body is stored nowhere.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+20
−0
internal/edge/pagecache_test.go+20 −0
diff --git a/internal/edge/pagecache_test.go b/internal/edge/pagecache_test.go| index 74e5d5eb1..5f0463079 100644 |
| --- a/internal/edge/pagecache_test.go |
| +++ b/internal/edge/pagecache_test.go |
| @@ -518,6 +518,26 @@ func TestPageOverflowStreamsAndStoresNothing(t *testing.T) { |
| } |
| } |
| +// A body shorter than its Content-Length (the app went away mid-body) is |
| +// never published as the whole page. |
| +func TestPageShortBodyIsNotStored(t *testing.T) { |
| + s := newPCScene(t, func(w http.ResponseWriter, r *http.Request) { |
| + h := w.Header() |
| + h.Set("Content-Type", "text/html") |
| + h.Set("Cache-Control", "public, s-maxage=600") |
| + h.Set(pageCacheHeader, "on") |
| + h.Set("Content-Length", "100") |
| + io.WriteString(w, strings.Repeat("s", 50)) |
| + }) |
| + for i := 0; i < 2; i++ { |
| + s.get("/p") |
| + } |
| + if n := s.b.n.Load(); n != 2 { |
| + t.Fatalf("the app saw %d requests, want 2", n) |
| + } |
| + s.wantNothingStored("a short body") |
| +} |
| + |
| // ---- requests that bypass -------------------------------------------------- |
| // Review Focus 4: a marked response to a request carrying a cookie is |