Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to fix intermittent failure in handle reading ranges with missing/invalid "Content-Range" header unit-test (PR 19114 follow-up) #19212

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading