11'use strict' ;
2- require ( '../common' ) ;
2+ const common = require ( '../common' ) ;
33const assert = require ( 'assert' ) ;
44const http = require ( 'http' ) ;
55
66const server = http . createServer ( function ( req , res ) {
77 res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
88 res . end ( 'Hello World\n' ) ;
9- } ) . listen ( 0 , function ( ) {
9+ } ) . listen ( 0 , common . mustCall ( function ( ) {
1010 const agent = new http . Agent ( { maxSockets : 1 } ) ;
1111
12- agent . on ( 'free' , function ( socket , host , port ) {
12+ agent . on ( 'free' , function ( socket ) {
1313 console . log ( 'freeing socket. destroyed? ' , socket . destroyed ) ;
1414 } ) ;
1515
@@ -20,7 +20,7 @@ const server = http.createServer(function(req, res) {
2020 path : '/'
2121 } ;
2222
23- const request1 = http . get ( requestOptions , function ( response ) {
23+ const request1 = http . get ( requestOptions , common . mustCall ( function ( response ) {
2424 // assert request2 is queued in the agent
2525 const key = agent . getName ( requestOptions ) ;
2626 assert . strictEqual ( agent . requests [ key ] . length , 1 ) ;
@@ -29,7 +29,7 @@ const server = http.createServer(function(req, res) {
2929 console . log ( 'request1 socket closed' ) ;
3030 } ) ;
3131 response . pipe ( process . stdout ) ;
32- response . on ( 'end' , function ( ) {
32+ response . on ( 'end' , common . mustCall ( function ( ) {
3333 console . log ( 'response1 done' ) ;
3434 /////////////////////////////////
3535 //
@@ -48,17 +48,17 @@ const server = http.createServer(function(req, res) {
4848 // assert request2 was removed from the queue
4949 assert ( ! agent . requests [ key ] ) ;
5050 console . log ( "waiting for request2.onSocket's nextTick" ) ;
51- process . nextTick ( function ( ) {
51+ process . nextTick ( common . mustCall ( function ( ) {
5252 // assert that the same socket was not assigned to request2,
5353 // since it was destroyed.
5454 assert . notStrictEqual ( request1 . socket , request2 . socket ) ;
5555 assert ( ! request2 . socket . destroyed , 'the socket is destroyed' ) ;
56- } ) ;
56+ } ) ) ;
5757 } ) ;
58- } ) ;
59- } ) ;
58+ } ) ) ;
59+ } ) ) ;
6060
61- const request2 = http . get ( requestOptions , function ( response ) {
61+ const request2 = http . get ( requestOptions , common . mustCall ( function ( response ) {
6262 assert ( ! request2 . socket . destroyed ) ;
6363 assert ( request1 . socket . destroyed ) ;
6464 // assert not reusing the same socket, since it was destroyed.
@@ -82,5 +82,5 @@ const server = http.createServer(function(req, res) {
8282 if ( gotResponseEnd && gotClose )
8383 server . close ( ) ;
8484 }
85- } ) ;
86- } ) ;
85+ } ) ) ;
86+ } ) ) ;
0 commit comments