Description

Currently the response body is stored as a string inside the response object. When it concerns big responses, like file downloads, this can take up quite some memory and you might go over PHP's memory limit.

To avoid such situations it would be nice to be able to write the body (after processing the transfer-encoding, NOT the raw body) directly into a PHP stream / file.

Comments

Posted by julien PAULI (doctorrock83) on 2009-05-20T01:13:54.000+0000

File download should not pass throught the MVC system, but should directly be served by the WebServer (Apache's mod_xsendfile is good for that)
Even if the dispatching may end on a file to be served, then it should send a 3xx HTTP response code to make the browser equest for it directly.

Am I wrong or did I miss something ? Perhaps you have a use-case to provide ?

Posted by Kristof Coomans (cyberwolf) on 2009-05-20T02:33:12.000+0000

Hi Julien

I think you missed the point, or I lacked in making my issue report clear enough, as I am talking not about MVC but about responses to requests made with Zend_Http_Client.

The full raw HTTP response body is now as a string inside the protected member variable $response->body, using up memory.

Posted by julien PAULI (doctorrock83) on 2009-05-20T03:12:47.000+0000

Yes yes, all my fault of not reading deeply the subject.

So I agree with your issue, if I can provide some patch, I would ;-)

Posted by Benjamin Eberlei (beberlei) on 2009-07-05T03:26:23.000+0000

This doesnt make sense imho, since the raw response is put together in one piece anyways for processing you have the complete response at one point in time no matter what and can reach memory limit with that.

Posted by Kristof Coomans (cyberwolf) on 2009-07-05T03:53:48.000+0000

Hi Benjamin, that's exactly my point, that in certain cases you would not want to have the raw response kept in memory but instead written to a stream (a file stream for example) as the data gradually comes in.

Downloading bigger files from Amazon S3 on a limited PHP environment is now impossible exactly because of the current implementation.