[wp-trac] [WordPress Trac] #16236: Method to stream file downloads in HTTP API, to reduce update memory footprint
WordPress Trac
wp-trac at lists.automattic.com
Thu Mar 24 18:54:01 UTC 2011
#16236: Method to stream file downloads in HTTP API, to reduce update memory
footprint
----------------------------+-----------------------
Reporter: markjaquith | Owner: sivel
Type: task (blessed) | Status: accepted
Priority: normal | Milestone: 3.2
Component: HTTP | Version:
Severity: normal | Resolution:
Keywords: has-patch |
----------------------------+-----------------------
Comment (by sivel):
The results of my testing look good. GET and HEAD requests using cURL
seem to populate headers correctly. Here are my results from streaming
the wordpress-3.1.zip directly to a file:
Testing curl:
{{{
array(5) {
["headers"]=>
array(8) {
["server"]=>
string(5) "nginx"
["date"]=>
string(29) "Thu, 24 Mar 2011 18:43:50 GMT"
["content-type"]=>
string(15) "application/zip"
["connection"]=>
string(5) "close"
["pragma"]=>
string(8) "no-cache"
["cache-control"]=>
string(7) "private"
["content-description"]=>
string(13) "File Transfer"
["content-disposition"]=>
string(38) "attachment; filename=wordpress-3.1.zip"
}
["body"]=>
bool(true)
["response"]=>
array(2) {
["code"]=>
int(200)
["message"]=>
string(2) "OK"
}
["cookies"]=>
array(0) {
}
["filename"]=>
string(34) "/Users/matt/tmp/wordpress/curl.zip"
}
Calculated MD5 (76904d048685a5642fe322e450abb388) matches MD5
(76904d048685a5642fe322e450abb388) of ZIP
Max Memory Usage: 16.821MB
}}}
Testing streams:
{{{
array(5) {
["headers"]=>
array(8) {
["server"]=>
string(5) "nginx"
["date"]=>
string(29) "Thu, 24 Mar 2011 18:44:04 GMT"
["content-type"]=>
string(15) "application/zip"
["connection"]=>
string(5) "close"
["pragma"]=>
string(8) "no-cache"
["cache-control"]=>
string(7) "private"
["content-description"]=>
string(13) "File Transfer"
["content-disposition"]=>
string(38) "attachment; filename=wordpress-3.1.zip"
}
["body"]=>
string(0) ""
["response"]=>
array(2) {
["code"]=>
string(3) "200"
["message"]=>
string(2) "OK"
}
["cookies"]=>
array(0) {
}
["filename"]=>
string(37) "/Users/matt/tmp/wordpress/streams.zip"
}
Calculated MD5 (76904d048685a5642fe322e450abb388) matches MD5
(76904d048685a5642fe322e450abb388) of ZIP
Max Memory Usage: 16.821MB
}}}
Testing fsockopen:
{{{
array(5) {
["headers"]=>
array(8) {
["server"]=>
string(5) "nginx"
["date"]=>
string(29) "Thu, 24 Mar 2011 18:44:21 GMT"
["content-type"]=>
string(15) "application/zip"
["connection"]=>
string(5) "close"
["pragma"]=>
string(8) "no-cache"
["cache-control"]=>
string(7) "private"
["content-description"]=>
string(13) "File Transfer"
["content-disposition"]=>
string(38) "attachment; filename=wordpress-3.1.zip"
}
["body"]=>
string(0) ""
["response"]=>
array(2) {
["code"]=>
string(3) "200"
["message"]=>
string(2) "OK"
}
["cookies"]=>
array(0) {
}
["filename"]=>
string(39) "/Users/matt/tmp/wordpress/fsockopen.zip"
}
Calculated MD5 (76904d048685a5642fe322e450abb388) matches MD5
(76904d048685a5642fe322e450abb388) of ZIP
Max Memory Usage: 16.821MB
}}}
Testing http_extension:
{{{
array(5) {
["headers"]=>
array(9) {
["server"]=>
string(5) "nginx"
["date"]=>
string(29) "Thu, 24 Mar 2011 18:44:40 GMT"
["content-type"]=>
string(15) "application/zip"
["transfer-encoding"]=>
string(7) "chunked"
["connection"]=>
string(5) "close"
["pragma"]=>
string(8) "no-cache"
["cache-control"]=>
string(7) "private"
["content-description"]=>
string(13) "File Transfer"
["content-disposition"]=>
string(38) "attachment; filename=wordpress-3.1.zip"
}
["body"]=>
string(0) ""
["response"]=>
array(2) {
["code"]=>
int(200)
["message"]=>
string(2) "OK"
}
["cookies"]=>
array(0) {
}
["filename"]=>
string(44) "/Users/matt/tmp/wordpress/http_extension.zip"
}
Calculated MD5 (76904d048685a5642fe322e450abb388) matches MD5
(76904d048685a5642fe322e450abb388) of ZIP
Max Memory Usage: 25.63MB
}}}
As expected exthttp shows higher memory usage.
As mentioned in a previous comment your latest patch has some extra code
changes for wp_list_pluck, that should probably be stripped before commit.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16236#comment:33>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list