1
1
'use strict' ;
2
- require ( '../common' ) ;
2
+ const common = require ( '../common' ) ;
3
3
const assert = require ( 'assert' ) ;
4
4
const http = require ( 'http' ) ;
5
5
6
6
const server = http . createServer ( function ( req , res ) {
7
7
res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
8
8
res . end ( 'Hello World\n' ) ;
9
- } ) . listen ( 0 , function ( ) {
9
+ } ) . listen ( 0 , common . mustCall ( function ( ) {
10
10
const agent = new http . Agent ( { maxSockets : 1 } ) ;
11
11
12
- agent . on ( 'free' , function ( socket , host , port ) {
12
+ agent . on ( 'free' , function ( socket ) {
13
13
console . log ( 'freeing socket. destroyed? ' , socket . destroyed ) ;
14
14
} ) ;
15
15
@@ -20,7 +20,7 @@ const server = http.createServer(function(req, res) {
20
20
path : '/'
21
21
} ;
22
22
23
- const request1 = http . get ( requestOptions , function ( response ) {
23
+ const request1 = http . get ( requestOptions , common . mustCall ( function ( response ) {
24
24
// assert request2 is queued in the agent
25
25
const key = agent . getName ( requestOptions ) ;
26
26
assert . strictEqual ( agent . requests [ key ] . length , 1 ) ;
@@ -29,7 +29,7 @@ const server = http.createServer(function(req, res) {
29
29
console . log ( 'request1 socket closed' ) ;
30
30
} ) ;
31
31
response . pipe ( process . stdout ) ;
32
- response . on ( 'end' , function ( ) {
32
+ response . on ( 'end' , common . mustCall ( function ( ) {
33
33
console . log ( 'response1 done' ) ;
34
34
/////////////////////////////////
35
35
//
@@ -48,17 +48,17 @@ const server = http.createServer(function(req, res) {
48
48
// assert request2 was removed from the queue
49
49
assert ( ! agent . requests [ key ] ) ;
50
50
console . log ( "waiting for request2.onSocket's nextTick" ) ;
51
- process . nextTick ( function ( ) {
51
+ process . nextTick ( common . mustCall ( function ( ) {
52
52
// assert that the same socket was not assigned to request2,
53
53
// since it was destroyed.
54
54
assert . notStrictEqual ( request1 . socket , request2 . socket ) ;
55
55
assert ( ! request2 . socket . destroyed , 'the socket is destroyed' ) ;
56
- } ) ;
56
+ } ) ) ;
57
57
} ) ;
58
- } ) ;
59
- } ) ;
58
+ } ) ) ;
59
+ } ) ) ;
60
60
61
- const request2 = http . get ( requestOptions , function ( response ) {
61
+ const request2 = http . get ( requestOptions , common . mustCall ( function ( response ) {
62
62
assert ( ! request2 . socket . destroyed ) ;
63
63
assert ( request1 . socket . destroyed ) ;
64
64
// assert not reusing the same socket, since it was destroyed.
@@ -82,5 +82,5 @@ const server = http.createServer(function(req, res) {
82
82
if ( gotResponseEnd && gotClose )
83
83
server . close ( ) ;
84
84
}
85
- } ) ;
86
- } ) ;
85
+ } ) ) ;
86
+ } ) ) ;
0 commit comments