mirror of
https://github.com/denoland/deno
synced 2024-08-27 12:00:17 +00:00
fix(node): update req.socket
on WS upgrade (#21984)
Update the `req.socket` to be a `net.Socket` from `FakeSocket` Fixes #21979
This commit is contained in:
parent
2141543105
commit
66ff28c21e
|
@ -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" +
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue