@@ -116,7 +116,7 @@ class Server {
116116 return promise ;
117117 }
118118
119- finish ( status , headers , req , res , promise , callback ) {
119+ finish ( status , headers , req , res , promise , callback , streaming ) {
120120 const result = {
121121 status,
122122 headers,
@@ -142,7 +142,7 @@ class Server {
142142 } else {
143143 // Don't end the request here, if we're streaming;
144144 // it's taken care of in `prototype.stream`.
145- if ( status !== 200 || req . method !== 'GET' ) {
145+ if ( ! streaming ) {
146146 res . writeHead ( status , headers ) ;
147147 res . end ( ) ;
148148 }
@@ -201,8 +201,8 @@ class Server {
201201 promise = new ( events . EventEmitter ) ;
202202 let pathname ;
203203
204- const finish = function ( status , headers ) {
205- that . finish ( status , headers , req , res , promise , callback ) ;
204+ const finish = function ( status , headers , streaming ) {
205+ that . finish ( status , headers , req , res , promise , callback , streaming ) ;
206206 } ;
207207
208208 try {
@@ -367,8 +367,8 @@ class Server {
367367 res . writeHead ( status , headers ) ;
368368
369369 this . stream ( key , files , length , startByte , res , function ( e ) {
370- if ( e ) { return finish ( 500 , { } ) }
371- finish ( status , headers ) ;
370+ if ( e ) { return finish ( 500 , { } , true ) }
371+ finish ( status , headers , true ) ;
372372 } ) ;
373373 }
374374 }
0 commit comments