Magento "Cannot send headers" with downloadable products

I have a Magento store selling very large (2 - 4 GB) downloadable files. Whenever someone is downloading a file and if they try to continue browsing while the file continues to download, the browser stalls until it times out, throwing this error:

"Cannot send headers; headers already sent in /home/xyz/public_html/app/code/core/Mage/Downloadable/Helper/Download.php, line 282"

I have checked and the Download.php file does not contain empty spaces that I can see. Plus, it only happens when someone tries to continue browsing during a download in the same browser. Opening another browser and everything is smooth and fast, so apparently Magento gets stuck with a single connection with the client?

Another symptom: While the download is in progress, clicking anywhere else on the site just stalls, as mentioned above. However if during the not-going-anywhere period I cancel the file download, then the new page loads immediately. Meaning that cancelling the download somehow liberates the browser for other connections.

Environment:

I was originally running the server with mod_fcgi and eaccelerator but it kept timing out during long downloads, even after playing with all the FCGI settings I could find, so it is now running with SuPHP.

Apache 2.2 / cPanel 11.30 / CentOS 5.5 / Dedicated server 4 GB RAM / Magento 1.4.2

If it helps, this is the website: http://store.gmvbodybuilding.com

I promise to save a kitty or plant a tree and name them after whomever helps figure this out!

:)

Answers


If Magento's using the default file-based PHP session handler, the stall will be due to the session file being locked by the download script. You'd need to issue an explicit session_write_close() in the download script, BEFORE the download starts. That'll free up/unlock the session file and allow the user to browser other pages on the site. Otherwise, each request that comes in while the download is in progress will hang on session_start() that particular script tries to get its own lock on the session file.


Need Your Help

Jquery modal pop up causing page to scroll

javascript jquery html css

So I have a modal window that is causing the page to scroll down. It adds #login-box to the url but that div id is not a set place. I thought about adding a div to the html but that wouldn't work b...

How to do svn update without password on crontab

bash svn ubuntu ssh cron

I'm new to svn and ssh. I'm trying to do svn update of 5 repositories in my local system every 3 hours on crontab.