Archived
1
0

Handle permessage-deflate on sockets

With this the extension host is working again.
This commit is contained in:
Asher
2021-03-02 16:42:25 -06:00
parent 150138e04b
commit 4d3d1b844d
7 changed files with 30 additions and 10 deletions

View File

@ -207,5 +207,8 @@ wsRouter.ws("/", ensureAuthenticated, async (req) => {
`Sec-WebSocket-Accept: ${reply}`,
].join("\r\n") + "\r\n\r\n",
)
await vscode.sendWebsocket(req.ws, req.query)
// TODO: Parse this header properly. Currently unused so haven't bothered.
const extensions = req.headers["sec-websocket-extensions"]
const permessageDeflate = extensions ? extensions.includes("permessage-deflate") : false
await vscode.sendWebsocket(req.ws, req.query, permessageDeflate)
})

View File

@ -120,12 +120,12 @@ export class VscodeProvider {
/**
* VS Code expects a raw socket. It will handle all the web socket frames.
*/
public async sendWebsocket(socket: net.Socket, query: ipc.Query): Promise<void> {
public async sendWebsocket(socket: net.Socket, query: ipc.Query, permessageDeflate: boolean): Promise<void> {
const vscode = await this._vscode
// TLS sockets cannot be transferred to child processes so we need an
// in-between. Non-TLS sockets will be returned as-is.
const socketProxy = await this.socketProvider.createProxy(socket)
this.send({ type: "socket", query }, vscode, socketProxy)
this.send({ type: "socket", query, permessageDeflate }, vscode, socketProxy)
}
private send(message: ipc.CodeServerMessage, vscode?: cp.ChildProcess, socket?: net.Socket): void {