Issues

ZF-6736: Allow writing the response body into a stream

Issue Type: Improvement Created: 2009-05-20T00:49:59.000+0000 Last Updated: 2009-11-24T14:14:31.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Kristof Coomans (cyberwolf) Assignee: Stanislav Malyshev (stas) Tags: - Zend_Http_Client

Related issues: - ZF-6729

Attachments:

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.

$client = new Zend_Http_client('http://example.com/somefile'); $response = $client->request();

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.

Posted by Stanislav Malyshev (stas) on 2009-11-16T17:18:50.000+0000

I think I know how to make it work.

Posted by Stanislav Malyshev (stas) on 2009-11-24T14:14:29.000+0000

Solution checked into trunk.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts