File tree Expand file tree Collapse file tree 1 file changed +27
-16
lines changed Expand file tree Collapse file tree 1 file changed +27
-16
lines changed Original file line number Diff line number Diff line change @@ -240,22 +240,33 @@ class IncomingForm extends EventEmitter {
240
240
. on ( 'aborted' , ( ) => {
241
241
this . emit ( 'aborted' ) ;
242
242
this . _error ( new FormidableError ( 'Request aborted' , errors . aborted ) ) ;
243
- } )
244
- . on ( 'data' , ( buffer ) => {
245
- try {
246
- this . write ( buffer ) ;
247
- } catch ( err ) {
248
- this . _error ( err ) ;
249
- }
250
- } )
251
- . on ( 'end' , ( ) => {
252
- if ( this . error ) {
253
- return ;
254
- }
255
- if ( this . _parser ) {
256
- this . _parser . end ( ) ;
257
- }
258
- } ) ;
243
+ } )
244
+
245
+ switch ( this . headers [ 'content-encoding' ] ) {
246
+ case "gzip" :
247
+ pipe = require ( "zlib" ) . createGunzip ( ) ;
248
+ break ;
249
+ case "deflate" :
250
+ pipe = require ( "zlib" ) . createInflate ( ) ;
251
+ break ;
252
+ case "br" :
253
+ pipe = require ( "zlib" ) . createBrotliDecompress ( ) ;
254
+ break ;
255
+ case "compress" :
256
+ pipe = require ( "zlib" ) . createUnzip ( ) ;
257
+ break ;
258
+
259
+ default :
260
+ pipe = node_stream . Transform ( {
261
+ transform : function ( chunk , encoding , callback ) {
262
+ callback ( null , chunk ) ;
263
+ }
264
+
265
+ } )
266
+ }
267
+ pipe . on ( "data" , datafn ) . on ( 'end' , endfn ) ;
268
+ req . pipe ( pipe )
269
+
259
270
if ( promise ) {
260
271
return promise ;
261
272
}
You can’t perform that action at this time.
0 commit comments