@@ -354,9 +354,16 @@ for (const factory of [
354
354
t . test ( 'should follow redirections when going cross origin' , async t => {
355
355
const [ server1 , server2 , server3 ] = await startRedirectingChainServers ( t )
356
356
357
+ const agent = new Agent ( {
358
+ keepAliveTimeout : 1000 ,
359
+ keepAliveMaxTimeout : 1000
360
+ } )
361
+ t . teardown ( agent . close . bind ( agent ) )
362
+
357
363
const { statusCode, headers, body : bodyStream , context : { history } } = await undici . request ( `http://${ server1 } ` , {
358
364
method : 'POST' ,
359
- maxRedirections : 10
365
+ maxRedirections : 10 ,
366
+ dispatcher : agent
360
367
} )
361
368
362
369
const body = await bodyStream . text ( )
@@ -381,6 +388,7 @@ t.test('should handle errors (callback)', t => {
381
388
keepAliveTimeout : 1000 ,
382
389
keepAliveMaxTimeout : 1000
383
390
} )
391
+ t . teardown ( agent . close . bind ( agent ) )
384
392
385
393
undici . request (
386
394
'http://localhost:0' ,
@@ -399,6 +407,7 @@ t.test('should handle errors (promise)', async t => {
399
407
keepAliveTimeout : 1000 ,
400
408
keepAliveMaxTimeout : 1000
401
409
} )
410
+ t . teardown ( agent . close . bind ( agent ) )
402
411
try {
403
412
await undici . request ( 'http://localhost:0' , { maxRedirections : 10 , dispatcher : agent } )
404
413
t . fail ( 'Did not throw' )
@@ -412,6 +421,7 @@ t.test('removes authorization header on third party origin', async t => {
412
421
keepAliveTimeout : 1000 ,
413
422
keepAliveMaxTimeout : 1000
414
423
} )
424
+ t . teardown ( agent . close . bind ( agent ) )
415
425
const [ server1 ] = await startRedirectingWithAuthorization ( t , 'secret' )
416
426
const { body : bodyStream } = await undici . request ( `http://${ server1 } ` , {
417
427
maxRedirections : 10 ,
@@ -431,6 +441,7 @@ t.test('removes cookie header on third party origin', async t => {
431
441
keepAliveTimeout : 1000 ,
432
442
keepAliveMaxTimeout : 1000
433
443
} )
444
+ t . teardown ( agent . close . bind ( agent ) )
434
445
const [ server1 ] = await startRedirectingWithCookie ( t , 'a=b' )
435
446
const { body : bodyStream } = await undici . request ( `http://${ server1 } ` , {
436
447
maxRedirections : 10 ,
0 commit comments