File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,10 @@ function compression (options) {
8989 // proxy
9090
9191 res . write = function write ( chunk , encoding , callback ) {
92+ if ( isFinished ( res ) || ended ) {
93+ return _write . apply ( this , arguments )
94+ }
95+
9296 if ( ! res . headersSent ) {
9397 this . writeHead ( this . statusCode )
9498 }
@@ -103,6 +107,10 @@ function compression (options) {
103107 }
104108
105109 res . end = function end ( chunk , encoding , callback ) {
110+ if ( isFinished ( res ) || ended ) {
111+ return _end . apply ( this , arguments )
112+ }
113+
106114 if ( ! callback ) {
107115 if ( typeof chunk === 'function' ) {
108116 callback = chunk
@@ -226,11 +234,6 @@ function compression (options) {
226234 res . setHeader ( 'Content-Encoding' , method )
227235 res . removeHeader ( 'Content-Length' )
228236
229- // emit error on response
230- stream . on ( 'error' , function ( err ) {
231- res . emit ( 'error' , err )
232- } )
233-
234237 // compression
235238 stream . on ( 'data' , function onStreamData ( chunk ) {
236239 if ( isFinished ( res ) ) {
You can’t perform that action at this time.
0 commit comments