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
473473get 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
480478get socket ( ) {
@@ -700,12 +698,11 @@ class Http2ServerResponse extends Stream{
700698if ( chunk !== null && chunk !== undefined )
701699this . write ( chunk , encoding ) ;
702700
703- const isFinished = this . finished ;
704701state . headRequest = stream . headRequest ;
705702state . ending = true ;
706703
707704if ( typeof cb === 'function' ) {
708- if ( isFinished )
705+ if ( stream . writableEnded )
709706this . once ( 'finish' , cb ) ;
710707else
711708stream . once ( 'finish' , cb ) ;
@@ -714,7 +711,7 @@ class Http2ServerResponse extends Stream{
714711if ( ! stream . headersSent )
715712this . writeHead ( this [ kState ] . statusCode ) ;
716713
717- if ( isFinished )
714+ if ( this [ kState ] . closed || stream . destroyed )
718715onStreamCloseResponse . call ( stream ) ;
719716else
720717stream . 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
151151const server = createServer ( mustCall ( ( request , response ) => {
152- strictEqual ( response . finished , true ) ;
153152strictEqual ( response . writableEnded , false ) ;
153+ strictEqual ( response . finished , false ) ;
154154response . writeHead ( HTTP_STATUS_OK , { foo : 'bar' } ) ;
155+ strictEqual ( response . finished , false ) ;
155156response . end ( 'data' , mustCall ( ) ) ;
156157strictEqual ( response . writableEnded , true ) ;
158+ strictEqual ( response . finished , true ) ;
157159} ) ) ;
158160server . listen ( 0 , mustCall ( ( ) => {
159161const { port } = server . address ( ) ;
You can’t perform that action at this time.
0 commit comments