Stream access to bodyDescription:
------------
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:
--------------schmidt
schmidthttp://pear.php.net/bugs/15881
HTTP_Request2 Feature/Change Request
Reported by schmidt
2009-02-07T00:31:24+00:00
PHP: Irrelevant OS: Package Version:
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:
--------------]]>HTTP_Request2 Feature/Change Request
Reported by schmidt
2009-02-07T00:31:24+00:00
PHP: Irrelevant OS: Package Version:
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:
--------------]]>2009-02-07T00:31:24+00:00
avb [2009-04-04 02:41] http://pear.php.net/bugs/15881#1238812893
<div id="changeset">
<span class="removed">-Status: Verified</span>
<span class="added">+Status: Closed</span>
</div>
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.]]><div id="changeset">
<span class="removed">-Status: Verified</span>
<span class="added">+Status: Closed</span>
</div>
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.]]>2009-04-04T02:41:33+00:00
avb [2009-02-08 01:20] http://pear.php.net/bugs/15881#1234056011
<div id="changeset">
<span class="removed">-Status: Open</span>
<span class="added">+Status: Verified</span>
<span class="removed">-Assigned To:</span>
<span class="added">+Assigned To: avb</span>
<span class="removed">-Roadmap Versions:</span>
<span class="added">+Roadmap Versions: 2.0.0beta1</span>
</div>
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...]]><div id="changeset">
<span class="removed">-Status: Open</span>
<span class="added">+Status: Verified</span>
<span class="removed">-Assigned To:</span>
<span class="added">+Assigned To: avb</span>
<span class="removed">-Roadmap Versions:</span>
<span class="added">+Roadmap Versions: 2.0.0beta1</span>
</div>
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-08T01:20:11+00:00
doconnor [2009-02-07 12:30] http://pear.php.net/bugs/15881#1234009839
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...]]>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-07T12:30:39+00:00