summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit_node/http_test.ts4
-rw-r--r--ext/node/polyfills/http.ts2
2 files changed, 5 insertions, 1 deletions
diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts
index 91e2f5703..3573416f8 100644
--- a/cli/tests/unit_node/http_test.ts
+++ b/cli/tests/unit_node/http_test.ts
@@ -716,7 +716,9 @@ Deno.test(
});
// @ts-ignore it's a socket for real
let serverSocket;
- server.on("upgrade", (_req, socket, _head) => {
+ server.on("upgrade", (req, socket, _head) => {
+ // https://github.com/denoland/deno/issues/21979
+ assert(req.socket?.write);
socket.write(
"HTTP/1.1 101 Web Socket Protocol Handshake\r\n" +
"Upgrade: WebSocket\r\n" +
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts
index fe5896534..9356dde0a 100644
--- a/ext/node/polyfills/http.ts
+++ b/ext/node/polyfills/http.ts
@@ -1637,6 +1637,8 @@ export class ServerImpl extends EventEmitter {
const socket = new Socket({
handle: new TCP(constants.SERVER, conn),
});
+ // Update socket held by `req`.
+ req.socket = socket;
this.emit("upgrade", req, socket, Buffer.from([]));
return response;
} else {