[wp-trac] [WordPress Trac] #27021: Add more context to the http_api_curl action
WordPress Trac
noreply at wordpress.org
Wed Feb 5 16:42:35 UTC 2014
#27021: Add more context to the http_api_curl action
-------------------------+-----------------------------
Reporter: kovshenin | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: HTTP API | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
Currently the http_api_curl action just passes the cURL handle, which is
not very useful without more context, like what URL was requested and what
the arguments were.
A simple use case is `CURLOPT_TIMEOUT_MS` which was removed in r12472 due
to bugginess with some versions of PHP and cURL, but which works pretty
well on newer versions, so with a more useful action, it could easily be
implemented in a plugin:
{{{
function better_curl_timeout( $handle, $r ) {
if ( defined( 'CURLOPT_CONNECTTIMEOUT_MS' ) && defined(
'CURLOPT_TIMEOUT_MS' ) ) {
$timeout_ms = (int) ceil( 1000 * $r['timeout'] );
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT_MS,
$timeout_ms );
curl_setopt( $handle, CURLOPT_TIMEOUT_MS, $timeout_ms );
}
}
add_action( 'http_api_curl', 'better_curl_timeout', 10, 2 );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27021>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list