diff --git a/test/webserver.mjs b/test/webserver.mjs index dd2ae735ecbd1..2f92637ca2651 100644 --- a/test/webserver.mjs +++ b/test/webserver.mjs @@ -189,7 +189,7 @@ class WebServer { if (this.verbose) { console.log(url); } - this.#serveFile(response, localURL, fileSize); + this.#serveFile(response, localURL, url.searchParams, fileSize); } async #serveDirectoryIndex(response, url, localUrl) { @@ -287,7 +287,7 @@ class WebServer { response.end(""); } - #serveFile(response, fileURL, fileSize) { + #serveFile(response, fileURL, searchParams, fileSize) { const stream = fs.createReadStream(fileURL, { flags: "rs" }); stream.on("error", error => { response.writeHead(500); @@ -304,6 +304,12 @@ class WebServer { expireTime.setSeconds(expireTime.getSeconds() + this.cacheExpirationTime); response.setHeader("Expires", expireTime.toUTCString()); } + + // Support test in `test/unit/network_spec.js`. + if (searchParams.has("test-network-break-ranges")) { + // Refer to the comment in `redirectHandler` below. + response.setHeader("Cache-Control", "no-store,max-age=0"); + } response.writeHead(200); stream.pipe(response); }