@@ -42,34 +42,12 @@ const updatedValues = new Map([
42
42
function variations ( iter , port , cb ) {
43
43
const { done, value } = iter . next ( ) ;
44
44
if ( done ) {
45
- return common . mustCall ( cb ) ;
46
- } else {
47
- const [ key , val ] = value ;
48
45
return common . mustCall ( ( res ) => {
49
46
res . resume ( ) ;
50
47
https . globalAgent . once ( 'free' , common . mustCall ( ( ) => {
51
- https . get (
52
- Object . assign ( { } , getBaseOptions ( port ) , { [ key ] : val } ) ,
53
- variations ( iter , port , cb )
54
- ) ;
55
- } ) ) ;
56
- } ) ;
57
- }
58
- }
59
-
60
- server . listen ( 0 , common . mustCall ( ( ) => {
61
- const port = server . address ( ) . port ;
62
- const globalAgent = https . globalAgent ;
63
- globalAgent . keepAlive = true ;
64
- https . get ( getBaseOptions ( port ) , variations (
65
- updatedValues . entries ( ) ,
66
- port ,
67
- common . mustCall ( ( res ) => {
68
- res . resume ( ) ;
69
- globalAgent . once ( 'free' , common . mustCall ( ( ) => {
70
48
// Verify that different keep-alived connections are created
71
49
// for the base call and each variation
72
- const keys = Object . keys ( globalAgent . freeSockets ) ;
50
+ const keys = Object . keys ( https . globalAgent . freeSockets ) ;
73
51
assert . strictEqual ( keys . length , 1 + updatedValues . size ) ;
74
52
let i = 1 ;
75
53
for ( const [ , value ] of updatedValues ) {
@@ -80,9 +58,26 @@ server.listen(0, common.mustCall(() => {
80
58
) ;
81
59
i ++ ;
82
60
}
83
- globalAgent . destroy ( ) ;
61
+ https . globalAgent . destroy ( ) ;
84
62
server . close ( ) ;
85
63
} ) ) ;
86
- } )
87
- ) ) ;
64
+ } ) ;
65
+ } else {
66
+ const [ key , val ] = value ;
67
+ return common . mustCall ( ( res ) => {
68
+ res . resume ( ) ;
69
+ https . globalAgent . once ( 'free' , common . mustCall ( ( ) => {
70
+ https . get (
71
+ Object . assign ( { } , getBaseOptions ( port ) , { [ key ] : val } ) ,
72
+ variations ( iter , port , cb )
73
+ ) ;
74
+ } ) ) ;
75
+ } ) ;
76
+ }
77
+ }
78
+
79
+ server . listen ( 0 , common . mustCall ( ( ) => {
80
+ const port = server . address ( ) . port ;
81
+ https . globalAgent . keepAlive = true ;
82
+ https . get ( getBaseOptions ( port ) , variations ( updatedValues . entries ( ) , port ) ) ;
88
83
} ) ) ;
0 commit comments