@@ -87,14 +87,6 @@ protected function iterateBuffer()
8787 }
8888
8989 if ($ this ->nextChunkIsLength ) {
90- if (substr ($ this ->buffer , 0 , 3 ) === "0 \r\n" ) {
91- // We've reached the end of the stream
92- $ this ->reachedEnd = true ;
93- $ this ->emit ('end ' );
94- $ this ->close ();
95- return false ;
96- }
97-
9890 $ crlfPosition = strpos ($ this ->buffer , static ::CRLF );
9991 if ($ crlfPosition === false && strlen ($ this ->buffer ) > 1024 ) {
10092 $ this ->emit ('error ' , [
@@ -106,17 +98,21 @@ protected function iterateBuffer()
10698 if ($ crlfPosition === false ) {
10799 return false ; // Chunk header hasn't completely come in yet
108100 }
109- $ this ->nextChunkIsLength = false ;
110101 $ lengthChunk = substr ($ this ->buffer , 0 , $ crlfPosition );
111102 if (strpos ($ lengthChunk , '; ' ) !== false ) {
112103 list ($ lengthChunk ) = explode ('; ' , $ lengthChunk , 2 );
113104 }
114105 if ($ lengthChunk !== '' ) {
115106 $ lengthChunk = ltrim ($ lengthChunk , "0 " );
116107 if ($ lengthChunk === '' ) {
117- $ lengthChunk = "0 " ;
108+ // We've reached the end of the stream
109+ $ this ->reachedEnd = true ;
110+ $ this ->emit ('end ' );
111+ $ this ->close ();
112+ return false ;
118113 }
119114 }
115+ $ this ->nextChunkIsLength = false ;
120116 if (dechex (hexdec ($ lengthChunk )) !== strtolower ($ lengthChunk )) {
121117 $ this ->emit ('error ' , [
122118 new Exception ('Unable to validate " ' . $ lengthChunk . '" as chunk length header ' ),
0 commit comments