MCPcopy Index your code
hub / github.com/coder/code-server / handleUpgrade

Function handleUpgrade

src/node/wsRouter.ts:16–32  ·  view source on GitHub ↗
(app: express.Express, server: http.Server)

Source from the content-addressed store, hash-verified

14}
15
16export const handleUpgrade = (app: express.Express, server: http.Server): void => {
17 server.on("upgrade", (req, socket, head) => {
18 socket.pause()
19
20 const wreq = req as InternalWebsocketRequest
21 wreq.ws = socket
22 wreq.head = head
23 wreq._ws_handled = false
24
25 // Send the request off to be handled by Express.
26 ;(app as any).handle(wreq, new http.ServerResponse(wreq), () => {
27 if (!wreq._ws_handled) {
28 socket.end("HTTP/1.1 404 Not Found\r\n\r\n")
29 }
30 })
31 })
32}
33
34export type WebSocketHandler = (
35 req: WebsocketRequest,

Callers 2

listenUpgradeMethod · 0.90
createAppFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected