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

Bug #19458 sendChunk not sending last payload when size equals multiple of bufferSize
Submitted: 2012-06-06 19:50 UTC
From: julien_etter Assigned:
Status: Open Package: HTTP_Download (version 1.1.4)
PHP Version: 5.2.11 OS: any
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


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:
MUST BE VALID
Solve the problem : 25 + 37 = ?

 
 [2012-06-06 19:50 UTC] julien_etter (Julien Etter)
Description: ------------ In sendChunk method: 917 while (($length -= $this->bufferSize) > 0) { 918 $this->flush(fread($this->handle, $this- >bufferSize)); 919 $this->throttleDelay and $this->sleep(); 920 } 921 if ($length) { 922 $this->flush(fread($this->handle, $this- >bufferSize + $length)); 923 } will not take care of the last payload if it is exactly equals to the bufferSize as test line 917 will return false as well as test line 921. Should line 921 be changed to: 921 if ($length <= 0) { Test script: --------------- Using the default bufferSize of 2M (2097152 bytes), download any file with a size of n*2097152, where n is an integer. Expected result: ---------------- The whole file to be downloaded. Actual result: -------------- The whole file minus bufferSize is downloaded, as the size transferred doesn't match the content-Length header, browsers will "hang"

Comments

 [2013-06-27 19:20 UTC] pookah (Marc Pookah)
We can confirm this problem. A file of 3*2097152 bytes results in an 2*2097152 download. Firefox 22 did not hang, though. dd if=/dev/zero of=pruefvermerk.beratung.pdf bs=6291456 count=1 The suggested change in line 921 works.