File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -568,6 +568,11 @@ class Http2ServerResponse extends Stream {
568568 if ( this [ kStream ] . headersSent )
569569 throw new ERR_HTTP2_HEADERS_SENT ( ) ;
570570
571+ // If the stream is destroyed, we return false,
572+ // like require('http').
573+ if ( this . stream . destroyed )
574+ return false ;
575+
571576 if ( typeof statusMessage === 'string' )
572577 statusMessageWarn ( ) ;
573578
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const common = require ( '../common' ) ;
4+ if ( ! common . hasCrypto )
5+ common . skip ( 'missing crypto' ) ;
6+ const http2 = require ( 'http2' ) ;
7+
8+ // Check that writeHead, write and end do not crash in compatibility mode
9+
10+ const server = http2 . createServer ( common . mustCall ( ( req , res ) => {
11+ // destroy the stream first
12+ req . stream . destroy ( ) ;
13+
14+ res . writeHead ( 200 ) ;
15+ res . write ( 'hello ' ) ;
16+ res . end ( 'world' ) ;
17+ } ) ) ;
18+
19+ server . listen ( 0 , common . mustCall ( ( ) => {
20+ const client = http2 . connect ( `http://localhost:${ server . address ( ) . port } ` ) ;
21+
22+ const req = client . request ( ) ;
23+ req . on ( 'response' , common . mustNotCall ( ) ) ;
24+ req . on ( 'close' , common . mustCall ( ( arg ) => {
25+ client . close ( ) ;
26+ server . close ( ) ;
27+ } ) ) ;
28+ req . resume ( ) ;
29+ } ) ) ;
You can’t perform that action at this time.
0 commit comments