Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.1

Bug #19934 Infinite loop with stream wrapper passed as upload
Submitted: 2013-05-06 17:16 UTC
From: dmitriytrt Assigned: avb
Status: Closed Package: HTTP_Request2 (version 2.1.1)
PHP Version: 5.4.8 OS: Windows 7 x86
Roadmaps: (Not assigned)    

Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem : 37 - 25 = ?

 [2013-05-06 17:16 UTC] dmitriytrt (Dmitriy Trt)
Description: ------------ The same file passed as a real path works fine, but fails into infinite loop when passed as a URI with underlying stream wrapper. In HTTP_Request2_MultipartBody::read() there is a wrong assumption that fread($this->_uploads[$pos]['fp'], $length) always returns $length bytes or reaches the end of file, it's not always true. When working with stream wrappers and reading with the $length larger than chunk size (8192) the fread() returns string of different size and leads to infinite loop in HTTP_Request2_Adapter_Socket::writeBody() where the actual data length is measured. PHP manual describes this situation with stream sockets (last condition that stops read): I'm attaching the patch with quick fix.


 [2013-05-06 17:19 UTC] dmitriytrt (Dmitriy Trt)
 [2014-01-12 02:29 UTC] avb (Alexey Borzov)
-Status: Open +Status: Closed -Assigned To: +Assigned To: avb
Thanks, fixed in Git.