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