File tree Expand file tree Collapse file tree 1 file changed +6
-19
lines changed Expand file tree Collapse file tree 1 file changed +6
-19
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22require ( '../common' ) ;
3- const assert = require ( 'assert' ) ;
43const http = require ( 'http' ) ;
54const net = require ( 'net' ) ;
5+ const Countdown = require ( '../common/countdown' ) ;
66
77const big = Buffer . alloc ( 16 * 1024 , 'A' ) ;
88
99const COUNT = 1e4 ;
1010
11- let received = 0 ;
11+ const countdown = new Countdown ( COUNT , ( ) => {
12+ server . close ( ) ;
13+ client . end ( ) ;
14+ } ) ;
1215
1316let client ;
1417const server = http . createServer ( function ( req , res ) {
1518 res . end ( big , function ( ) {
16- if ( ++ received === COUNT ) {
17- server . close ( ) ;
18- client . end ( ) ;
19- }
19+ countdown . dec ( ) ;
2020 } ) ;
2121} ) . listen ( 0 , function ( ) {
2222 const req = 'GET / HTTP/1.1\r\n\r\n' . repeat ( COUNT ) ;
2323 client = net . connect ( this . address ( ) . port , function ( ) {
2424 client . write ( req ) ;
2525 } ) ;
26-
27- // Just let the test terminate instead of hanging
28- client . on ( 'close' , function ( ) {
29- if ( received !== COUNT )
30- server . close ( ) ;
31- } ) ;
3226 client . resume ( ) ;
3327} ) ;
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