Don't send permessage-deflate header if not supported (#2993)

This commit is contained in:
Asher 2021-03-29 12:59:36 -05:00 committed by GitHub
parent 6cf904a39b
commit 18ace7b906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -210,7 +210,9 @@ wsRouter.ws("/", ensureAuthenticated, async (req) => {
// TODO: Parse this header properly. // TODO: Parse this header properly.
const extensions = req.headers["sec-websocket-extensions"] const extensions = req.headers["sec-websocket-extensions"]
const permessageDeflate = extensions ? extensions.includes("permessage-deflate") : false const permessageDeflate = extensions ? extensions.includes("permessage-deflate") : false
responseHeaders.push("Sec-WebSocket-Extensions: permessage-deflate; server_max_window_bits=15") if (permessageDeflate) {
responseHeaders.push("Sec-WebSocket-Extensions: permessage-deflate; server_max_window_bits=15")
}
req.ws.write(responseHeaders.join("\r\n") + "\r\n\r\n") req.ws.write(responseHeaders.join("\r\n") + "\r\n\r\n")