File tree 2 files changed +7
-8
lines changed
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 {
471
471
}
472
472
473
473
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 ;
478
476
}
479
477
480
478
get socket ( ) {
@@ -700,12 +698,11 @@ class Http2ServerResponse extends Stream {
700
698
if ( chunk !== null && chunk !== undefined )
701
699
this . write ( chunk , encoding ) ;
702
700
703
- const isFinished = this . finished ;
704
701
state . headRequest = stream . headRequest ;
705
702
state . ending = true ;
706
703
707
704
if ( typeof cb === 'function' ) {
708
- if ( isFinished )
705
+ if ( stream . writableEnded )
709
706
this . once ( 'finish' , cb ) ;
710
707
else
711
708
stream . once ( 'finish' , cb ) ;
@@ -714,7 +711,7 @@ class Http2ServerResponse extends Stream {
714
711
if ( ! stream . headersSent )
715
712
this . writeHead ( this [ kState ] . statusCode ) ;
716
713
717
- if ( isFinished )
714
+ if ( this [ kState ] . closed || stream . destroyed )
718
715
onStreamCloseResponse . call ( stream ) ;
719
716
else
720
717
stream . end ( ) ;
Original file line number Diff line number Diff line change @@ -149,11 +149,13 @@ const {
149
149
// Http2ServerResponse.end is necessary on HEAD requests in compat
150
150
// for http1 compatibility
151
151
const server = createServer ( mustCall ( ( request , response ) => {
152
- strictEqual ( response . finished , true ) ;
153
152
strictEqual ( response . writableEnded , false ) ;
153
+ strictEqual ( response . finished , false ) ;
154
154
response . writeHead ( HTTP_STATUS_OK , { foo : 'bar' } ) ;
155
+ strictEqual ( response . finished , false ) ;
155
156
response . end ( 'data' , mustCall ( ) ) ;
156
157
strictEqual ( response . writableEnded , true ) ;
158
+ strictEqual ( response . finished , true ) ;
157
159
} ) ) ;
158
160
server . listen ( 0 , mustCall ( ( ) => {
159
161
const { port } = server . address ( ) ;
You can’t perform that action at this time.
0 commit comments