Req #15881 [Ver->Csd]: Stream access to body

From: Date: Fri, 03 Apr 2009 21:41:33 +0000
Subject: Req #15881 [Ver->Csd]: Stream access to body
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-301@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=15881&edit=1 ID: 15881 Updated by: borz_off@cs.msu.su Reported By: schmidt at php dot net Summary: Stream access to body -Status: Verified +Status: Closed Type: Feature/Change Request Package: HTTP_Request2 PHP Version: Irrelevant Assigned To: avb Roadmap Versions: New Comment: -Status: Verified +Status: Closed Fixed in CVS: it is now possible to set 'store_body' config parameter to false to prevent keeping the whole body in a response object. Observers may be used to save parts of response body to disc while it is being received. Previous Comments: ------------------------------------------------------------------------ [2009-02-07 20:20:11] avb -Status: Open +Status: Verified -Assigned To: +Assigned To: avb -Roadmap Versions: +Roadmap Versions: 2.0.0beta1 Hmm, I now see that I forgot to port saveBody parameter from old HTTP_Request. You can use Observers now to save parts of the response body as it is being received, but the body is still saved in the property of the response object. Also it may be useful to limit the memory consumption even if not saving huge response bodies via Observers by using e.g. php://temp/ stream wrapper in HTTP_Request2_Response. Need to research further... ------------------------------------------------------------------------ [2009-02-07 07:30:39] doconnor Couldn't you simply implement a HTTP_Request2_Stream_Adapter which extends one of the other classes, and returns a HTTP_Request2_StreamResponse which implements your desired behaviour? IE; no need to rewrite huge chunks... ------------------------------------------------------------------------ [2009-02-06 19:31:24] schmidt Description: ------------ The current implementation stores the response body in a variable (contrary to the request body that may be consumed from a file). In order to download very big files (many gigabytes), it would be useful if the body could be read using a stream resource instead, i.e. like this: $response = $request->send(); $fp = $response->getBodyStream(); while (!feof($fp)) { $line = fgets($fp); // do stuff } fclose($fp); I'm afraid implementing this feature will require a rather big restructuring of the code. I would like to use this feature in the Services_Amazon_S3 package. Test script: --------------- Expected result: ---------------- Actual result: -------------- ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=15881&edit=1

« previous php.pear.bugs (#301) next »