File tree 1 file changed +6
-19
lines changed
1 file changed +6
-19
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
require ( '../common' ) ;
3
- const assert = require ( 'assert' ) ;
4
3
const http = require ( 'http' ) ;
5
4
const net = require ( 'net' ) ;
5
+ const Countdown = require ( '../common/countdown' ) ;
6
6
7
7
const big = Buffer . alloc ( 16 * 1024 , 'A' ) ;
8
8
9
9
const COUNT = 1e4 ;
10
10
11
- let received = 0 ;
11
+ const countdown = new Countdown ( COUNT , ( ) => {
12
+ server . close ( ) ;
13
+ client . end ( ) ;
14
+ } ) ;
12
15
13
16
let client ;
14
17
const server = http . createServer ( function ( req , res ) {
15
18
res . end ( big , function ( ) {
16
- if ( ++ received === COUNT ) {
17
- server . close ( ) ;
18
- client . end ( ) ;
19
- }
19
+ countdown . dec ( ) ;
20
20
} ) ;
21
21
} ) . listen ( 0 , function ( ) {
22
22
const req = new Array ( COUNT + 1 ) . join ( 'GET / HTTP/1.1\r\n\r\n' ) ;
23
23
client = net . connect ( this . address ( ) . port , function ( ) {
24
24
client . write ( req ) ;
25
25
} ) ;
26
-
27
- // Just let the test terminate instead of hanging
28
- client . on ( 'close' , function ( ) {
29
- if ( received !== COUNT )
30
- server . close ( ) ;
31
- } ) ;
32
26
client . resume ( ) ;
33
27
} ) ;
34
-
35
- process . on ( 'exit' , function ( ) {
36
- // The server should pause connection on pipeline flood, but it shoul still
37
- // resume it and finish processing the requests, when its output queue will
38
- // be empty again.
39
- assert . strictEqual ( received , COUNT ) ;
40
- } ) ;
You can’t perform that action at this time.
0 commit comments