MCPcopy
hub / github.com/nodejs/undici / pipeliningNonIdempotentWithBody

Function pipeliningNonIdempotentWithBody

test/client-pipelining.js:455–518  ·  view source on GitHub ↗
(bodyType)

Source from the content-addressed store, hash-verified

453})
454
455function pipeliningNonIdempotentWithBody (bodyType) {
456 test(`pipelining non-idempotent w body ${bodyType}`, async (t) => {
457 t = tspl(t, { plan: 4 })
458
459 const server = createServer({ joinDuplicateHeaders: true })
460 server.on('request', (req, res) => {
461 setImmediate(() => {
462 res.end('asd')
463 })
464 })
465 after(() => server.close())
466
467 server.listen(0, () => {
468 const client = new Client(`http://localhost:${server.address().port}`, {
469 pipelining: 2
470 })
471 after(() => client.close())
472 client.on('disconnect', () => {
473 if (!client.closed && !client.destroyed) {
474 t.fail('unexpected disconnect')
475 }
476 })
477
478 let ended = false
479 let reading = false
480 client.request({
481 path: '/',
482 method: 'POST',
483 body: maybeWrapStream(new Readable({
484 read () {
485 if (reading) {
486 return
487 }
488 reading = true
489 this.push('asd')
490 setImmediate(() => {
491 this.push(null)
492 ended = true
493 })
494 }
495 }), bodyType)
496 }, (err, data) => {
497 t.ifError(err)
498 data.body
499 .resume()
500 .on('end', () => {
501 t.ok(true, 'pass')
502 })
503 })
504
505 client.request({
506 path: '/',
507 method: 'GET',
508 idempotent: false
509 }, (err, data) => {
510 t.ifError(err)
511 t.strictEqual(ended, true)
512 data.body.resume()

Callers 1

Calls 9

createServerFunction · 0.85
maybeWrapStreamFunction · 0.85
listenMethod · 0.80
okMethod · 0.80
closeMethod · 0.65
resumeMethod · 0.65
onMethod · 0.45
endMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…