@@ -23,28 +23,24 @@ const serverOptions = {
23
23
function test ( fn ) {
24
24
if ( ! tests . length )
25
25
process . nextTick ( run ) ;
26
- tests . push ( fn ) ;
26
+ tests . push ( common . mustCall ( fn ) ) ;
27
27
}
28
28
29
29
function run ( ) {
30
30
const fn = tests . shift ( ) ;
31
31
if ( fn ) {
32
- console . log ( '# %s' , fn . name ) ;
33
32
fn ( run ) ;
34
- } else {
35
- console . log ( 'ok' ) ;
36
33
}
37
34
}
38
35
39
36
test ( function serverTimeout ( cb ) {
40
37
const server = https . createServer (
41
38
serverOptions ,
42
- common . mustCall ( function ( req , res ) {
43
- // just do nothing, we should get a
44
- // timeout event.
39
+ common . mustCall ( ( req , res ) => {
40
+ // just do nothing, we should get a timeout event.
45
41
} ) ) ;
46
- server . listen ( common . mustCall ( function ( ) {
47
- const s = server . setTimeout ( 50 , common . mustCall ( function ( socket ) {
42
+ server . listen ( common . mustCall ( ( ) => {
43
+ const s = server . setTimeout ( 50 , common . mustCall ( ( socket ) => {
48
44
socket . destroy ( ) ;
49
45
server . close ( ) ;
50
46
cb ( ) ;
@@ -60,19 +56,16 @@ test(function serverTimeout(cb) {
60
56
test ( function serverRequestTimeout ( cb ) {
61
57
const server = https . createServer (
62
58
serverOptions ,
63
- common . mustCall ( function ( req , res ) {
64
- // just do nothing, we should get a
65
- // timeout event.
66
- const s = req . setTimeout (
67
- 50 ,
68
- common . mustCall ( function ( socket ) {
69
- socket . destroy ( ) ;
70
- server . close ( ) ;
71
- cb ( ) ;
72
- } ) ) ;
59
+ common . mustCall ( ( req , res ) => {
60
+ // just do nothing, we should get a timeout event.
61
+ const s = req . setTimeout ( 50 , common . mustCall ( ( socket ) => {
62
+ socket . destroy ( ) ;
63
+ server . close ( ) ;
64
+ cb ( ) ;
65
+ } ) ) ;
73
66
assert . ok ( s instanceof http . IncomingMessage ) ;
74
67
} ) ) ;
75
- server . listen ( common . mustCall ( function ( ) {
68
+ server . listen ( common . mustCall ( ( ) => {
76
69
const req = https . request ( {
77
70
port : server . address ( ) . port ,
78
71
method : 'POST' ,
@@ -87,16 +80,16 @@ test(function serverRequestTimeout(cb) {
87
80
test ( function serverResponseTimeout ( cb ) {
88
81
const server = https . createServer (
89
82
serverOptions ,
90
- common . mustCall ( function ( req , res ) {
83
+ common . mustCall ( ( req , res ) => {
91
84
// just do nothing, we should get a timeout event.
92
- const s = res . setTimeout ( 50 , common . mustCall ( function ( socket ) {
85
+ const s = res . setTimeout ( 50 , common . mustCall ( ( socket ) => {
93
86
socket . destroy ( ) ;
94
87
server . close ( ) ;
95
88
cb ( ) ;
96
89
} ) ) ;
97
90
assert . ok ( s instanceof http . OutgoingMessage ) ;
98
91
} ) ) ;
99
- server . listen ( common . mustCall ( function ( ) {
92
+ server . listen ( common . mustCall ( ( ) => {
100
93
https . get ( {
101
94
port : server . address ( ) . port ,
102
95
rejectUnauthorized : false
@@ -107,18 +100,18 @@ test(function serverResponseTimeout(cb) {
107
100
test ( function serverRequestNotTimeoutAfterEnd ( cb ) {
108
101
const server = https . createServer (
109
102
serverOptions ,
110
- common . mustCall ( function ( req , res ) {
103
+ common . mustCall ( ( req , res ) => {
111
104
// just do nothing, we should get a timeout event.
112
105
const s = req . setTimeout ( 50 , common . mustNotCall ( ) ) ;
113
106
assert . ok ( s instanceof http . IncomingMessage ) ;
114
107
res . on ( 'timeout' , common . mustCall ( ) ) ;
115
108
} ) ) ;
116
- server . on ( 'timeout' , common . mustCall ( function ( socket ) {
109
+ server . on ( 'timeout' , common . mustCall ( ( socket ) => {
117
110
socket . destroy ( ) ;
118
111
server . close ( ) ;
119
112
cb ( ) ;
120
113
} ) ) ;
121
- server . listen ( common . mustCall ( function ( ) {
114
+ server . listen ( common . mustCall ( ( ) => {
122
115
https . get ( {
123
116
port : server . address ( ) . port ,
124
117
rejectUnauthorized : false
@@ -129,32 +122,32 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
129
122
test ( function serverResponseTimeoutWithPipeline ( cb ) {
130
123
let caughtTimeout = '' ;
131
124
let secReceived = false ;
132
- process . on ( 'exit' , function ( ) {
125
+ process . on ( 'exit' , ( ) => {
133
126
assert . strictEqual ( caughtTimeout , '/2' ) ;
134
127
} ) ;
135
- const server = https . createServer ( serverOptions , function ( req , res ) {
128
+ const server = https . createServer ( serverOptions , ( req , res ) => {
136
129
if ( req . url === '/2' )
137
130
secReceived = true ;
138
- const s = res . setTimeout ( 50 , function ( ) {
131
+ const s = res . setTimeout ( 50 , ( ) => {
139
132
caughtTimeout += req . url ;
140
133
} ) ;
141
134
assert . ok ( s instanceof http . OutgoingMessage ) ;
142
135
if ( req . url === '/1' ) res . end ( ) ;
143
136
} ) ;
144
- server . on ( 'timeout' , function ( socket ) {
137
+ server . on ( 'timeout' , common . mustCall ( ( socket ) => {
145
138
if ( secReceived ) {
146
139
socket . destroy ( ) ;
147
140
server . close ( ) ;
148
141
cb ( ) ;
149
142
}
150
- } ) ;
151
- server . listen ( common . mustCall ( function ( ) {
143
+ } ) ) ;
144
+ server . listen ( common . mustCall ( ( ) => {
152
145
const options = {
153
146
port : server . address ( ) . port ,
154
147
allowHalfOpen : true ,
155
148
rejectUnauthorized : false
156
149
} ;
157
- const c = tls . connect ( options , function ( ) {
150
+ const c = tls . connect ( options , ( ) => {
158
151
c . write ( 'GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
159
152
c . write ( 'GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
160
153
c . write ( 'GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
@@ -165,25 +158,25 @@ test(function serverResponseTimeoutWithPipeline(cb) {
165
158
test ( function idleTimeout ( cb ) {
166
159
const server = https . createServer (
167
160
serverOptions ,
168
- common . mustCall ( function ( req , res ) {
161
+ common . mustCall ( ( req , res ) => {
169
162
req . on ( 'timeout' , common . mustNotCall ( ) ) ;
170
163
res . on ( 'timeout' , common . mustNotCall ( ) ) ;
171
164
res . end ( ) ;
172
165
} ) ) ;
173
- const s = server . setTimeout ( 50 , common . mustCall ( function ( socket ) {
166
+ const s = server . setTimeout ( 50 , common . mustCall ( ( socket ) => {
174
167
socket . destroy ( ) ;
175
168
server . close ( ) ;
176
169
cb ( ) ;
177
170
} ) ) ;
178
171
assert . ok ( s instanceof https . Server ) ;
179
- server . listen ( common . mustCall ( function ( ) {
172
+ server . listen ( common . mustCall ( ( ) => {
180
173
const options = {
181
174
port : server . address ( ) . port ,
182
175
allowHalfOpen : true ,
183
176
rejectUnauthorized : false
184
177
} ;
185
- tls . connect ( options , function ( ) {
186
- this . write ( 'GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
178
+ const c = tls . connect ( options , ( ) => {
179
+ c . write ( 'GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
187
180
// Keep-Alive
188
181
} ) ;
189
182
} ) ) ;
0 commit comments