@@ -4,14 +4,13 @@ const common = require('../common');
4
4
const assert = require ( 'assert' ) ;
5
5
const http = require ( 'http' ) ;
6
6
7
- let requests = 0 ;
8
7
9
- http . createServer ( function ( req , res ) {
8
+ const server = http . createServer ( common . mustCall ( function ( req , res ) {
10
9
res . writeHead ( 200 ) ;
11
10
res . end ( 'ok' ) ;
11
+ } ) ) ;
12
12
13
- requests ++ ;
14
- } ) . listen ( 0 , function ( ) {
13
+ server . listen ( 0 , function ( ) {
15
14
const agent = new http . Agent ( ) ;
16
15
agent . defaultPort = this . address ( ) . port ;
17
16
@@ -30,16 +29,12 @@ http.createServer(function(req, res) {
30
29
31
30
http . request ( options , function ( res ) {
32
31
res . resume ( ) ;
33
- } ) . end ( ) ;
34
-
35
- process . on ( 'exit' , function ( ) {
36
- assert . strictEqual ( requests , 1 ) ;
37
-
32
+ server . close ( ) ;
38
33
assert . strictEqual ( options . host , undefined ) ;
39
34
assert . strictEqual ( options . hostname , common . localhostIPv4 ) ;
40
35
assert . strictEqual ( options . port , undefined ) ;
41
36
assert . strictEqual ( options . defaultPort , undefined ) ;
42
37
assert . strictEqual ( options . path , undefined ) ;
43
38
assert . strictEqual ( options . method , undefined ) ;
44
- } ) ;
45
- } ) . unref ( ) ;
39
+ } ) . end ( ) ;
40
+ } ) ;
0 commit comments