File tree 1 file changed +23
-1
lines changed
1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,13 @@ Readable.prototype.read = function(n) {
153
153
if ( ! chunk || ! chunk . length ) {
154
154
// eof
155
155
state . ended = true ;
156
+ if ( state . decoder ) {
157
+ chunk = state . decoder . end ( ) ;
158
+ if ( chunk && chunk . length ) {
159
+ state . buffer . push ( chunk ) ;
160
+ state . length += chunk . length ;
161
+ }
162
+ }
156
163
// if we've ended and we have some data left, then emit
157
164
// 'readable' now to make sure it gets picked up.
158
165
if ( ! sync ) {
@@ -395,11 +402,26 @@ Readable.prototype.wrap = function(stream) {
395
402
396
403
stream . on ( 'end' , function ( ) {
397
404
state . ended = true ;
398
- if ( state . length === 0 )
405
+ if ( state . decoder ) {
406
+ var chunk = state . decoder . end ( ) ;
407
+ if ( chunk && chunk . length ) {
408
+ state . buffer . push ( chunk ) ;
409
+ state . length += chunk . length ;
410
+ }
411
+ }
412
+
413
+ if ( state . length > 0 )
414
+ this . emit ( 'readable' ) ;
415
+ else
399
416
endReadable ( this ) ;
400
417
} . bind ( this ) ) ;
401
418
402
419
stream . on ( 'data' , function ( chunk ) {
420
+ if ( state . decoder )
421
+ chunk = state . decoder . write ( chunk ) ;
422
+ if ( ! chunk || ! chunk . length )
423
+ return ;
424
+
403
425
state . buffer . push ( chunk ) ;
404
426
state . length += chunk . length ;
405
427
this . emit ( 'readable' ) ;
You can’t perform that action at this time.
0 commit comments