[wp-trac] [WordPress Trac] #33055: Support Parallel HTTP Requests in WP_Http, et al
WordPress Trac
noreply at wordpress.org
Mon Jul 20 23:54:57 UTC 2015
#33055: Support Parallel HTTP Requests in WP_Http, et al
----------------------------+-------------------------------------
Reporter: wonderboymusic | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: HTTP API | Version:
Severity: normal | Keywords: has-patch needs-refresh
Focuses: |
----------------------------+-------------------------------------
HTTP-driven applications need to be performant. Being able to make
multiple HTTP requests asynchronously is vital to making this a reality.
Currently, WordPress only allows us to make one request at a time,
serially:
{{{
$req1 = wp_remote_get( 'http://failwhale.com/posts', [ 'timeout' => 2 ] );
$req2 = wp_remote_get( 'http://failwhale.com/burritos', [ 'timeout' => 2 ]
);
}}}
Wouldn't it be cool if we could do:
{{{
$responses = wp_remote_get( [
[ 'http://api.bandsintown.com/artists/Ed%20Sheeran.json?app_id=woo', [
'timeout' => 2 ] ],
[ 'http://api.bandsintown.com/artists/Taylor%20Swift.json?app_id=woo',
[ 'timeout' => 2 ] ]
] );
}}}
My patch does this by doing the following:
* Introduces `WP_Http_Request`
* If an array is passed to `WP_Http::request()`, automatically calls
`WP_Http::request_multi()`
* When multiple requests are made, hashes the request to the maintain a
reference generated by `WP_Http::hash_request()`
* Adds `WP_Http::_get_first_available_multi_transport()` to initially
support cURL only, we could also add support for PECL HTTP and
`HttpRequestPool`
* If an array of data is passed to `WP_Http::_dispatch_request()`, calls
`->request_multi()` instead of `->request()` on the approved multi
transport
* In `WP_Http_Curl`, does kung fu and jiu jitsu at the same time to
dynamically support streaming of multiple requests simultaneously via
`->__call()`
* Implements cURL Multi
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33055>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list