(baseUrl: string, requestTarget: string)
| 6 | |
| 7 | describe.runIf(isServe)('invalid request', () => { |
| 8 | const sendRawRequest = async (baseUrl: string, requestTarget: string) => { |
| 9 | return new Promise<string>((resolve, reject) => { |
| 10 | const parsedUrl = new URL(baseUrl) |
| 11 | |
| 12 | const buf: Buffer[] = [] |
| 13 | const client = net.createConnection( |
| 14 | { port: +parsedUrl.port, host: parsedUrl.hostname }, |
| 15 | () => { |
| 16 | client.write( |
| 17 | [ |
| 18 | `GET ${encodeURI(requestTarget)} HTTP/1.1`, |
| 19 | `Host: ${parsedUrl.host}`, |
| 20 | 'Connection: Close', |
| 21 | '\r\n', |
| 22 | ].join('\r\n'), |
| 23 | ) |
| 24 | }, |
| 25 | ) |
| 26 | client.on('data', (data) => { |
| 27 | buf.push(data) |
| 28 | }) |
| 29 | client.on('end', (hadError) => { |
| 30 | if (!hadError) { |
| 31 | resolve(Buffer.concat(buf).toString()) |
| 32 | } |
| 33 | }) |
| 34 | client.on('error', (err) => { |
| 35 | reject(err) |
| 36 | }) |
| 37 | }) |
| 38 | } |
| 39 | |
| 40 | const root = path |
| 41 | .resolve(import.meta.dirname.replace('playground', 'playground-temp'), '..') |
no test coverage detected