(controller, statusCode, _headers, socket)
| 120 | } |
| 121 | |
| 122 | onRequestUpgrade (controller, statusCode, _headers, socket) { |
| 123 | this.socket.off('close', this.abort) |
| 124 | |
| 125 | // TODO: Check statusCode? |
| 126 | |
| 127 | if (this.head && this.head.length) { |
| 128 | socket.unshift(this.head) |
| 129 | } |
| 130 | |
| 131 | setupSocket(socket) |
| 132 | |
| 133 | const headers = getHeaders({ |
| 134 | headers: controller.rawHeaders ?? [], |
| 135 | proxyName: this.proxyName, |
| 136 | httpVersion: this.httpVersion |
| 137 | }) |
| 138 | |
| 139 | let head = '' |
| 140 | for (let n = 0; n < headers.length; n += 2) { |
| 141 | head += `\r\n${headers[n]}: ${headers[n + 1]}` |
| 142 | } |
| 143 | |
| 144 | this.socket.write(`HTTP/1.1 101 Switching Protocols\r\nconnection: upgrade\r\nupgrade: websocket${head}\r\n\r\n`) |
| 145 | |
| 146 | pipeline(socket, this.socket, socket, this.callback) |
| 147 | } |
| 148 | |
| 149 | onResponseError (_controller, err) { |
| 150 | this.socket.off('close', this.abort) |
nothing calls this directly
no test coverage detected