File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -471,10 +471,8 @@ class Http2ServerResponse extends Stream {
471471 }
472472
473473 get finished ( ) {
474- const stream = this [ kStream ] ;
475- return stream . destroyed ||
476- stream . _writableState . ended ||
477- this [ kState ] . closed ;
474+ const state = this [ kState ] ;
475+ return state . ending ;
478476 }
479477
480478 get socket ( ) {
@@ -700,12 +698,11 @@ class Http2ServerResponse extends Stream {
700698 if ( chunk !== null && chunk !== undefined )
701699 this . write ( chunk , encoding ) ;
702700
703- const isFinished = this . finished ;
704701 state . headRequest = stream . headRequest ;
705702 state . ending = true ;
706703
707704 if ( typeof cb === 'function' ) {
708- if ( isFinished )
705+ if ( stream . writableEnded )
709706 this . once ( 'finish' , cb ) ;
710707 else
711708 stream . once ( 'finish' , cb ) ;
@@ -714,7 +711,7 @@ class Http2ServerResponse extends Stream {
714711 if ( ! stream . headersSent )
715712 this . writeHead ( this [ kState ] . statusCode ) ;
716713
717- if ( isFinished )
714+ if ( this [ kState ] . closed || stream . destroyed )
718715 onStreamCloseResponse . call ( stream ) ;
719716 else
720717 stream . end ( ) ;
Original file line number Diff line number Diff line change @@ -149,11 +149,13 @@ const {
149149 // Http2ServerResponse.end is necessary on HEAD requests in compat
150150 // for http1 compatibility
151151 const server = createServer ( mustCall ( ( request , response ) => {
152- strictEqual ( response . finished , true ) ;
153152 strictEqual ( response . writableEnded , false ) ;
153+ strictEqual ( response . finished , false ) ;
154154 response . writeHead ( HTTP_STATUS_OK , { foo : 'bar' } ) ;
155+ strictEqual ( response . finished , false ) ;
155156 response . end ( 'data' , mustCall ( ) ) ;
156157 strictEqual ( response . writableEnded , true ) ;
158+ strictEqual ( response . finished , true ) ;
157159 } ) ) ;
158160 server . listen ( 0 , mustCall ( ( ) => {
159161 const { port } = server . address ( ) ;
You can’t perform that action at this time.
0 commit comments