Files
ladybird/Tests/LibWeb/Text/input/Cache/http-memory-cache.html
Timothy Flynn 453764d3f0 LibHTTP: Do not respond to Range requests with cached full responses
If we have the response for a non-Range request in the memory cache, we
would previously use it in reply to Range requests. Similar to commit
878b00ae61f998a26aad7f50fae66cf969878ad6, we are just punting on Range
requests in the HTTP caches for now.
2026-01-10 09:02:41 -05:00

50 lines
1.5 KiB
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<script>
// FIXME: http-disk-cache.html should just run for both disk and memory caches. But our memory cache does not yet
// handle cache expiration, so for now, memory cache specific tests are here.
asyncTest(async done => {
const ALPHABET = "abcdefghijklmnabcdefghijklmnopqrstuvwxyz";
const server = httpTestServer();
let response, text;
await server.createEcho("OPTIONS", "/memory-cache-test/range", {
status: 200,
headers: {
"Access-Control-Allow-Headers": "Range",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Origin": location.origin,
},
});
const url = await server.createEcho("GET", "/memory-cache-test/range", {
status: 200,
body: ALPHABET,
headers: {
"Access-Control-Allow-Origin": location.origin,
"Cache-Control": "max-age=500",
},
});
response = await fetch(url, {
mode: "cors",
});
text = await response.text();
println(`Original response: "${text}"`);
response = await fetch(url, {
headers: {
Range: "bytes=10-20",
},
mode: "cors",
});
text = await response.text();
println(`Range response: "${text}"`);
done();
});
</script>