Assert 412 precondition responses keep no-store policy

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 03:43:14 +00:00
1 parent b80e1dcac2
commit ffa2756cf6
1 file changed
+16
+16
View File
@@ -352,6 +352,12 @@ async function main() {
`Smoke test failed: expected If-Match mismatch status 412, received ${ifMatchMismatchAsset.status}.`,
);
}
if ((ifMatchMismatchAsset.headers.get("cache-control") ?? "").toLowerCase() !== "no-store") {
throw new Error("Smoke test failed: expected cache-control=no-store on If-Match mismatch response.");
}
if ((ifMatchMismatchAsset.headers.get("x-content-type-options") ?? "").toLowerCase() !== "nosniff") {
throw new Error("Smoke test failed: expected nosniff on If-Match mismatch response.");
}
const staleUnmodifiedSince = new Date(parsedLastModifiedMs - 1_000).toUTCString();
const ifUnmodifiedSinceStaleAsset = await fetch(assetUrl, {
headers: {
@@ -363,6 +369,11 @@ async function main() {
`Smoke test failed: expected stale If-Unmodified-Since status 412, received ${ifUnmodifiedSinceStaleAsset.status}.`,
);
}
if ((ifUnmodifiedSinceStaleAsset.headers.get("cache-control") ?? "").toLowerCase() !== "no-store") {
throw new Error(
"Smoke test failed: expected cache-control=no-store on stale If-Unmodified-Since response.",
);
}
const ifUnmodifiedSinceCurrentAsset = await fetch(assetUrl, {
headers: {
"If-Unmodified-Since": assetLastModified,
@@ -455,6 +466,11 @@ async function main() {
`Smoke test failed: expected HEAD If-Match mismatch status 412, received ${ifMatchMismatchHeadAsset.status}.`,
);
}
if ((ifMatchMismatchHeadAsset.headers.get("cache-control") ?? "").toLowerCase() !== "no-store") {
throw new Error(
"Smoke test failed: expected cache-control=no-store on HEAD If-Match mismatch response.",
);
}
const rangeEnd = Math.min(15, assetContentLength - 1);
const rangedAsset = await fetch(assetUrl, {
headers: {