File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common' ) ;
3+ if ( ! common . hasCrypto )
4+ common . skip ( 'missing crypto' ) ;
5+ const http2 = require ( 'http2' ) ;
6+
7+ // Regression test for https://github.com/nodejs/node/issues/27416.
8+ // Check that received data is accounted for correctly in the maxSessionMemory
9+ // mechanism.
10+
11+ const bodyLength = 8192 ;
12+ const maxSessionMemory = 1 ; // 1 MB
13+ const requestCount = 1000 ;
14+
15+ const server = http2 . createServer ( { maxSessionMemory } ) ;
16+ server . on ( 'stream' , ( stream ) => {
17+ stream . respond ( ) ;
18+ stream . end ( ) ;
19+ } ) ;
20+
21+ server . listen ( common . mustCall ( ( ) => {
22+ const client = http2 . connect ( `http://localhost:${ server . address ( ) . port } ` , {
23+ maxSessionMemory
24+ } ) ;
25+
26+ function request ( ) {
27+ return new Promise ( ( resolve , reject ) => {
28+ const stream = client . request ( {
29+ ':method' : 'POST' ,
30+ 'content-length' : bodyLength
31+ } ) ;
32+ stream . on ( 'error' , reject ) ;
33+ stream . on ( 'response' , resolve ) ;
34+ stream . end ( 'a' . repeat ( bodyLength ) ) ;
35+ } ) ;
36+ }
37+
38+ ( async ( ) => {
39+ for ( let i = 0 ; i < requestCount ; i ++ ) {
40+ await request ( ) ;
41+ }
42+
43+ client . close ( ) ;
44+ server . close ( ) ;
45+ } ) ( ) . then ( common . mustCall ( ) ) ;
46+ } ) ) ;
You can’t perform that action at this time.
0 commit comments