File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
Expand file tree Collapse file tree 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) {
153153 if ( ! chunk || ! chunk . length ) {
154154 // eof
155155 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+ }
156163 // if we've ended and we have some data left, then emit
157164 // 'readable' now to make sure it gets picked up.
158165 if ( ! sync ) {
@@ -395,11 +402,26 @@ Readable.prototype.wrap = function(stream) {
395402
396403 stream . on ( 'end' , function ( ) {
397404 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
399416 endReadable ( this ) ;
400417 } . bind ( this ) ) ;
401418
402419 stream . on ( 'data' , function ( chunk ) {
420+ if ( state . decoder )
421+ chunk = state . decoder . write ( chunk ) ;
422+ if ( ! chunk || ! chunk . length )
423+ return ;
424+
403425 state . buffer . push ( chunk ) ;
404426 state . length += chunk . length ;
405427 this . emit ( 'readable' ) ;
You can’t perform that action at this time.
0 commit comments