(body, type)
| 218 | writeHeadersStartedWithBody(wrapWithAsyncIterable(createReadStream(__filename)), 'async-iterator') |
| 219 | |
| 220 | function writeBodyStartedWithBody (body, type) { |
| 221 | test(`Abort ${controllerName} while waiting response (write headers and write body started) (with body ${type})`, async (t) => { |
| 222 | const p = tspl(t, { plan: 2 }) |
| 223 | |
| 224 | const abortController = new AbortControllerImpl() |
| 225 | const server = createServer({ joinDuplicateHeaders: true }, (req, res) => { |
| 226 | res.writeHead(200, { 'content-type': 'text/plain' }) |
| 227 | res.write('hello') |
| 228 | }) |
| 229 | t.after(closeServerAsPromise(server)) |
| 230 | |
| 231 | server.listen(0, () => { |
| 232 | const client = new Client(`http://localhost:${server.address().port}`) |
| 233 | t.after(client.destroy.bind(client)) |
| 234 | |
| 235 | client.request({ path: '/', method: 'POST', body, signal: abortController.signal }, (err, response) => { |
| 236 | p.ifError(err) |
| 237 | response.body.on('data', () => { |
| 238 | abortController.abort() |
| 239 | }) |
| 240 | response.body.on('error', err => { |
| 241 | p.ok(err instanceof errors.RequestAbortedError || err instanceof DOMException) |
| 242 | }) |
| 243 | }) |
| 244 | }) |
| 245 | await p.completed |
| 246 | }) |
| 247 | } |
| 248 | |
| 249 | writeBodyStartedWithBody('hello', 'string') |
| 250 | writeBodyStartedWithBody(createReadStream(__filename), 'stream') |
no test coverage detected
searching dependent graphs…