This commit is contained in:
olevole
2023-02-26 23:51:44 +03:00
parent c2172953de
commit 25b7d56e41
8 changed files with 39 additions and 23 deletions

View File

@@ -391,7 +391,7 @@ class Server extends BaseServer {
abortUpgrade(socket, errorCode, errorContext);
return;
}
const head = Buffer.from(upgradeHead); // eslint-disable-line node/no-deprecated-api
const head = Buffer.from(upgradeHead);
upgradeHead = null;
// delegate to ws
this.ws.handleUpgrade(req, socket, head, websocket => {
@@ -468,7 +468,7 @@ class Server extends BaseServer {
// normalize path
path += "/";
function check(req) {
return path === req.url.substr(0, path.length);
return path === req.url.slice(0, path.length);
}
// cache and clean up listeners
const listeners = server.listeners("request").slice(0);
@@ -502,6 +502,9 @@ class Server extends BaseServer {
setTimeout(function () {
// @ts-ignore
if (socket.writable && socket.bytesWritten <= 0) {
socket.on("error", e => {
debug("error while destroying upgrade: %s", e.message);
});
return socket.end();
}
}, destroyUpgradeTimeout);