@@ -4,14 +4,13 @@ const common = require('../common');
44const assert = require ( 'assert' ) ;
55const http = require ( 'http' ) ;
66
7- let requests = 0 ;
87
9- http . createServer ( function ( req , res ) {
8+ const server = http . createServer ( common . mustCall ( function ( req , res ) {
109 res . writeHead ( 200 ) ;
1110 res . end ( 'ok' ) ;
11+ } ) ) ;
1212
13- requests ++ ;
14- } ) . listen ( 0 , function ( ) {
13+ server . listen ( 0 , function ( ) {
1514 const agent = new http . Agent ( ) ;
1615 agent . defaultPort = this . address ( ) . port ;
1716
@@ -30,16 +29,12 @@ http.createServer(function(req, res) {
3029
3130 http . request ( options , function ( res ) {
3231 res . resume ( ) ;
33- } ) . end ( ) ;
34-
35- process . on ( 'exit' , function ( ) {
36- assert . strictEqual ( requests , 1 ) ;
37-
32+ server . close ( ) ;
3833 assert . strictEqual ( options . host , undefined ) ;
3934 assert . strictEqual ( options . hostname , common . localhostIPv4 ) ;
4035 assert . strictEqual ( options . port , undefined ) ;
4136 assert . strictEqual ( options . defaultPort , undefined ) ;
4237 assert . strictEqual ( options . path , undefined ) ;
4338 assert . strictEqual ( options . method , undefined ) ;
44- } ) ;
45- } ) . unref ( ) ;
39+ } ) . end ( ) ;
40+ } ) ;
0 commit comments