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) {
89
89
// proxy
90
90
91
91
res . write = function write ( chunk , encoding , callback ) {
92
+ if ( isFinished ( res ) || ended ) {
93
+ return _write . apply ( this , arguments )
94
+ }
95
+
92
96
if ( ! res . headersSent ) {
93
97
this . writeHead ( this . statusCode )
94
98
}
@@ -103,6 +107,10 @@ function compression (options) {
103
107
}
104
108
105
109
res . end = function end ( chunk , encoding , callback ) {
110
+ if ( isFinished ( res ) || ended ) {
111
+ return _end . apply ( this , arguments )
112
+ }
113
+
106
114
if ( ! callback ) {
107
115
if ( typeof chunk === 'function' ) {
108
116
callback = chunk
@@ -226,11 +234,6 @@ function compression (options) {
226
234
res . setHeader ( 'Content-Encoding' , method )
227
235
res . removeHeader ( 'Content-Length' )
228
236
229
- // emit error on response
230
- stream . on ( 'error' , function ( err ) {
231
- res . emit ( 'error' , err )
232
- } )
233
-
234
237
// compression
235
238
stream . on ( 'data' , function onStreamData ( chunk ) {
236
239
if ( isFinished ( res ) ) {
You can’t perform that action at this time.
0 commit comments