@@ -162,9 +162,11 @@ describe('compression()', function () {
162
162
var resp
163
163
var server = createServer ( { threshold : 0 } , function ( req , res ) {
164
164
resp = res
165
+
165
166
res . on ( 'drain' , function ( ) {
166
167
drained = true
167
168
} )
169
+
168
170
res . setHeader ( 'Content-Type' , 'text/plain' )
169
171
res . write ( 'start' )
170
172
pressure ( )
@@ -179,21 +181,23 @@ describe('compression()', function () {
179
181
180
182
function complete ( ) {
181
183
if ( -- wait !== 0 ) return
182
- assert . ok ( drained )
183
184
done ( )
184
185
}
185
186
186
187
function pressure ( ) {
187
188
if ( ! buf || ! resp || ! client ) return
188
189
190
+ assert . ok ( ! drained )
191
+
189
192
while ( resp . write ( buf ) !== false ) {
190
193
resp . flush ( )
191
194
}
192
195
193
196
resp . on ( 'drain' , function ( ) {
194
- resp . write ( 'end' )
197
+ assert . ok ( resp . write ( 'end' ) )
195
198
resp . end ( )
196
199
} )
200
+
197
201
resp . on ( 'finish' , complete )
198
202
client . resume ( )
199
203
}
@@ -218,9 +222,11 @@ describe('compression()', function () {
218
222
var resp
219
223
var server = createServer ( { filter : function ( ) { return false } } , function ( req , res ) {
220
224
resp = res
225
+
221
226
res . on ( 'drain' , function ( ) {
222
227
drained = true
223
228
} )
229
+
224
230
res . setHeader ( 'Content-Type' , 'text/plain' )
225
231
res . write ( 'start' )
226
232
pressure ( )
@@ -235,7 +241,6 @@ describe('compression()', function () {
235
241
236
242
function complete ( ) {
237
243
if ( -- wait !== 0 ) return
238
- assert . ok ( drained )
239
244
done ( )
240
245
}
241
246
@@ -247,7 +252,8 @@ describe('compression()', function () {
247
252
}
248
253
249
254
resp . on ( 'drain' , function ( ) {
250
- resp . write ( 'end' )
255
+ assert . ok ( drained )
256
+ assert . ok ( resp . write ( 'end' ) )
251
257
resp . end ( )
252
258
} )
253
259
resp . on ( 'finish' , complete )
0 commit comments