From fae9aeba8d7eeba1d05a1fbab682ce561bc5ec15 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 03:44:59 +0000 Subject: [PATCH] Assert range requests honor If-Match preconditions Co-authored-by: Theo Browne --- apps/t3/scripts/smoke-test.mjs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/apps/t3/scripts/smoke-test.mjs b/apps/t3/scripts/smoke-test.mjs index 9f80065010..73a04a1705 100644 --- a/apps/t3/scripts/smoke-test.mjs +++ b/apps/t3/scripts/smoke-test.mjs @@ -358,6 +358,22 @@ async function main() { if ((ifMatchMismatchAsset.headers.get("x-content-type-options") ?? "").toLowerCase() !== "nosniff") { throw new Error("Smoke test failed: expected nosniff on If-Match mismatch response."); } + const ifMatchRangeMismatchAsset = await fetch(assetUrl, { + headers: { + Range: "bytes=0-15", + "If-Match": "\"definitely-different-etag\"", + }, + }); + if (ifMatchRangeMismatchAsset.status !== 412) { + throw new Error( + `Smoke test failed: expected ranged If-Match mismatch status 412, received ${ifMatchRangeMismatchAsset.status}.`, + ); + } + if (ifMatchRangeMismatchAsset.headers.get("content-range") !== null) { + throw new Error( + "Smoke test failed: expected no content-range on ranged If-Match mismatch response.", + ); + } const staleUnmodifiedSince = new Date(parsedLastModifiedMs - 1_000).toUTCString(); const ifUnmodifiedSinceStaleAsset = await fetch(assetUrl, { headers: { @@ -482,6 +498,23 @@ async function main() { "Smoke test failed: expected cache-control=no-store on HEAD If-Match mismatch response.", ); } + const ifMatchRangeMismatchHeadAsset = await fetch(assetUrl, { + method: "HEAD", + headers: { + Range: "bytes=0-15", + "If-Match": "\"definitely-different-etag\"", + }, + }); + if (ifMatchRangeMismatchHeadAsset.status !== 412) { + throw new Error( + `Smoke test failed: expected HEAD ranged If-Match mismatch status 412, received ${ifMatchRangeMismatchHeadAsset.status}.`, + ); + } + if (ifMatchRangeMismatchHeadAsset.headers.get("content-range") !== null) { + throw new Error( + "Smoke test failed: expected no content-range on HEAD ranged If-Match mismatch response.", + ); + } const rangeEnd = Math.min(15, assetContentLength - 1); const rangedAsset = await fetch(assetUrl, { headers: {