MCPcopy Create free account
hub / github.com/honojs/node-server / rejectUpgradeRequest

Function rejectUpgradeRequest

src/websocket.ts:95–104  ·  view source on GitHub ↗
(socket: Duplex, status: number, responseHeaders?: Headers)

Source from the content-addressed store, hash-verified

93}
94
95const rejectUpgradeRequest = (socket: Duplex, status: number, responseHeaders?: Headers) => {
96 const responseLines = ['Connection: close', 'Content-Length: 0']
97 appendResponseHeaders(responseLines, responseHeaders)
98
99 socket.end(
100 `HTTP/1.1 ${status.toString()} ${STATUS_CODES[status] ?? ''}\r\n` +
101 `${responseLines.join('\r\n')}\r\n` +
102 '\r\n'
103 )
104}
105
106const createUpgradeRequest = (request: IncomingMessage): Request => {
107 const protocol = (request.socket as { encrypted?: boolean }).encrypted ? 'https' : 'http'

Callers 1

setupWebSocketFunction · 0.85

Calls 1

appendResponseHeadersFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…