Propagate web-search cancellation

This commit is contained in:
2026-07-25 21:18:08 -07:00
parent 802fc5339e
commit b4efe82ce2
19 changed files with 634 additions and 91 deletions

View File

@@ -1,6 +1,7 @@
import http from "node:http";
let websocketUpgrades = 0;
let slowRequests = 0;
const server = http.createServer((request, response) => {
const url = new URL(request.url, "http://mock-search.test");
@@ -23,6 +24,23 @@ const server = http.createServer((request, response) => {
</body></html>`);
return;
}
if (url.pathname === "/slow") {
slowRequests += 1;
let closed = false;
response.once("close", () => {
if (closed) return;
closed = true;
slowRequests -= 1;
});
response.writeHead(200, { "Content-Type": "text/plain" });
response.write("pending");
return;
}
if (url.pathname === "/slow-count") {
response.writeHead(200, { "Content-Type": "text/plain" });
response.end(String(slowRequests));
return;
}
if (url.pathname === "/redirect-private") {
response.writeHead(302, { Location: "http://127.0.0.1:8765/private" });
response.end();