( request: Request, url: string | URL, headers: Headers )
| 148 | url.searchParams.set('ptyId', ptyId); |
| 149 | |
| 150 | const headers = new Headers(); |
| 151 | for (const name of ['Upgrade', 'Connection', 'Sec-WebSocket-Key', 'Sec-WebSocket-Version']) { |
| 152 | const value = request.headers.get(name); |
| 153 | if (value !== null) headers.set(name, value); |
| 154 | } |
| 155 | if (authorization !== undefined) headers.set('Authorization', authorization); |
| 156 | |
| 157 | return new Request(url, { method: 'GET', headers }); |
| 158 | } |
| 159 | |
| 160 | // TODO: the name is not very clear. I thought it is a termination of a websocket, not that websocket is for PTY |
| 161 | async function handleTerminalWebSocket( |
| 162 | request: Request, |
| 163 | env: Env, |
| 164 | ctx?: SecretsExecutionContext |
| 165 | ): Promise<Response> { |
| 166 | const upgradeHeader = request.headers.get('Upgrade'); |
| 167 | if (upgradeHeader?.toLowerCase() !== 'websocket') { |
no test coverage detected