Skip to content

Commit

Permalink
Try to fix intermittent failure in `handle reading ranges with missin…
Browse files Browse the repository at this point in the history
…g/invalid "Content-Range" header` unit-test (PR 19114 follow-up)

Implements mozilla#19114 (comment), which didn't seem necessary at the time since the unit-tests passed (many times) in PR 19114.
  • Loading branch information
Snuffleupagus committed Dec 10, 2024
1 parent 4d22881 commit 7f0e55c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/webserver.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -287,7 +287,7 @@ class WebServer {
response.end("</body></html>");
}

#serveFile(response, fileURL, fileSize) {
#serveFile(response, fileURL, searchParams, fileSize) {
const stream = fs.createReadStream(fileURL, { flags: "rs" });
stream.on("error", error => {
response.writeHead(500);
Expand All @@ -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);
}
Expand Down

0 comments on commit 7f0e55c

Please sign in to comment.