* Raw HTTP GET that lets us set an arbitrary `Host` header. Node's `fetch` * (undici) treats `Host` as a forbidden header and silently replaces it with * the URL host, so the Host-allowlist test drives `node:http` directly.
( url: string, headers: Record<string, string>, )
| 229 | * the URL host, so the Host-allowlist test drives `node:http` directly. |
| 230 | */ |
| 231 | function rawHttpGet( |
| 232 | url: string, |
| 233 | headers: Record<string, string>, |
| 234 | ): Promise<{ status: number; body: string }> { |
| 235 | return new Promise((resolve, reject) => { |
| 236 | const u = new URL(url); |
| 237 | const req = httpRequest( |
| 238 | { |
| 239 | hostname: u.hostname, |
| 240 | port: u.port, |
| 241 | path: `${u.pathname}${u.search}`, |
| 242 | method: 'GET', |
| 243 | headers, |
| 244 | }, |
| 245 | (res) => { |
| 246 | let body = ''; |
| 247 | res.on('data', (chunk: Buffer) => { |
| 248 | body += chunk.toString(); |
| 249 | }); |
| 250 | res.on('end', () => resolve({ status: res.statusCode ?? 0, body })); |
| 251 | }, |
| 252 | ); |
| 253 | req.on('error', reject); |
| 254 | req.end(); |
| 255 | }); |
| 256 | } |
| 257 | |
| 258 | describe('public-bind §3.5 end-to-end (M6.7)', () => { |
| 259 | /** |
no test coverage detected