File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Flags: --expose-http2
2+ 'use strict' ;
3+
4+ const common = require ( '../common' ) ;
5+ if ( ! common . hasCrypto )
6+ common . skip ( 'missing crypto' ) ;
7+ const assert = require ( 'assert' ) ;
8+ const http2 = require ( 'http2' ) ;
9+
10+ const server = http2 . createServer ( ) ;
11+
12+ // Test that ERR_HTTP2_INVALID_STREAM is thrown when a stream is destroyed
13+ // before calling stream.priority
14+ server . on ( 'stream' , common . mustCall ( onStream ) ) ;
15+
16+ function onStream ( stream , headers , flags ) {
17+ stream . session . destroy ( ) ;
18+ assert . throws ( ( ) => stream . priority ( ) ,
19+ common . expectsError ( {
20+ code : 'ERR_HTTP2_INVALID_STREAM' ,
21+ message : / ^ T h e s t r e a m h a s b e e n d e s t r o y e d $ /
22+ } ) ) ;
23+ }
24+
25+ server . listen ( 0 ) ;
26+
27+ server . on ( 'listening' , common . mustCall ( ( ) => {
28+
29+ const client = http2 . connect ( `http://localhost:${ server . address ( ) . port } ` ) ;
30+
31+ const req = client . request ( { ':path' : '/' } ) ;
32+
33+ req . on ( 'response' , common . mustNotCall ( ) ) ;
34+ req . resume ( ) ;
35+ req . on ( 'end' , common . mustCall ( ( ) => {
36+ server . close ( ) ;
37+ client . destroy ( ) ;
38+ } ) ) ;
39+ req . end ( ) ;
40+
41+ } ) ) ;
Original file line number Diff line number Diff line change 1+ // Flags: --expose-http2
2+ 'use strict' ;
3+
4+ const common = require ( '../common' ) ;
5+ if ( ! common . hasCrypto )
6+ common . skip ( 'missing crypto' ) ;
7+ const assert = require ( 'assert' ) ;
8+ const http2 = require ( 'http2' ) ;
9+
10+ const server = http2 . createServer ( ) ;
11+
12+ // Test that ERR_HTTP2_INVALID_STREAM is thrown when a stream is destroyed
13+ // before calling stream.rstStream
14+ server . on ( 'stream' , common . mustCall ( onStream ) ) ;
15+
16+ function onStream ( stream , headers , flags ) {
17+ stream . session . destroy ( ) ;
18+ assert . throws ( ( ) => stream . rstStream ( ) ,
19+ common . expectsError ( {
20+ code : 'ERR_HTTP2_INVALID_STREAM' ,
21+ message : / ^ T h e s t r e a m h a s b e e n d e s t r o y e d $ /
22+ } ) ) ;
23+ }
24+
25+ server . listen ( 0 ) ;
26+
27+ server . on ( 'listening' , common . mustCall ( ( ) => {
28+
29+ const client = http2 . connect ( `http://localhost:${ server . address ( ) . port } ` ) ;
30+
31+ const req = client . request ( { ':path' : '/' } ) ;
32+
33+ req . on ( 'response' , common . mustNotCall ( ) ) ;
34+ req . resume ( ) ;
35+ req . on ( 'end' , common . mustCall ( ( ) => {
36+ server . close ( ) ;
37+ client . destroy ( ) ;
38+ } ) ) ;
39+ req . end ( ) ;
40+
41+ } ) ) ;
Original file line number Diff line number Diff line change 1+ // Flags: --expose-http2
2+ 'use strict' ;
3+
4+ const common = require ( '../common' ) ;
5+ if ( ! common . hasCrypto )
6+ common . skip ( 'missing crypto' ) ;
7+ const assert = require ( 'assert' ) ;
8+ const http2 = require ( 'http2' ) ;
9+
10+ const server = http2 . createServer ( ) ;
11+
12+ // Test that stream.state getter returns and empty object
13+ // if the stream session has been destroyed
14+ server . on ( 'stream' , common . mustCall ( onStream ) ) ;
15+
16+ function onStream ( stream , headers , flags ) {
17+ stream . session . destroy ( ) ;
18+ assert . deepStrictEqual ( Object . create ( null ) , stream . state ) ;
19+ }
20+
21+ server . listen ( 0 ) ;
22+
23+ server . on ( 'listening' , common . mustCall ( ( ) => {
24+
25+ const client = http2 . connect ( `http://localhost:${ server . address ( ) . port } ` ) ;
26+
27+ const req = client . request ( { ':path' : '/' } ) ;
28+
29+ req . on ( 'response' , common . mustNotCall ( ) ) ;
30+ req . resume ( ) ;
31+ req . on ( 'end' , common . mustCall ( ( ) => {
32+ server . close ( ) ;
33+ client . destroy ( ) ;
34+ } ) ) ;
35+ req . end ( ) ;
36+
37+ } ) ) ;
You can’t perform that action at this time.
0 commit comments