mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 07:00:01 +00:00
Port Magpie from Snoopy to WP HTTP Request API. fixes #8082
git-svn-id: http://svn.automattic.com/wordpress/trunk@9553 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ac470da4bf
commit
0155abf585
@ -384,7 +384,6 @@ class MagpieRSS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
require_once( dirname(__FILE__) . '/class-snoopy.php');
|
|
||||||
|
|
||||||
if ( !function_exists('fetch_rss') ) :
|
if ( !function_exists('fetch_rss') ) :
|
||||||
/**
|
/**
|
||||||
@ -526,7 +525,7 @@ function fetch_rss ($url) {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve URL headers and content using Snoopy.
|
* Retrieve URL headers and content using WP HTTP Request API.
|
||||||
*
|
*
|
||||||
* @since unknown
|
* @since unknown
|
||||||
* @package External
|
* @package External
|
||||||
@ -534,21 +533,20 @@ endif;
|
|||||||
*
|
*
|
||||||
* @param string $url URL to retrieve
|
* @param string $url URL to retrieve
|
||||||
* @param array $headers Optional. Headers to send to the URL.
|
* @param array $headers Optional. Headers to send to the URL.
|
||||||
* @return Snoopy
|
* @return Snoopy style response
|
||||||
*/
|
*/
|
||||||
function _fetch_remote_file ($url, $headers = "" ) {
|
function _fetch_remote_file ($url, $headers = "" ) {
|
||||||
// Snoopy is an HTTP client in PHP
|
$resp = wp_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT));
|
||||||
$client = new Snoopy();
|
if ( is_wp_error($resp) ) {
|
||||||
$client->agent = apply_filters( 'magpie_user_agent', MAGPIE_USER_AGENT );
|
$resp = new stdClass;
|
||||||
$client->read_timeout = MAGPIE_FETCH_TIME_OUT;
|
$resp->status = 500;
|
||||||
$client->use_gzip = MAGPIE_USE_GZIP;
|
return $resp;
|
||||||
if (is_array($headers) ) {
|
|
||||||
$client->rawheaders = $headers;
|
|
||||||
}
|
}
|
||||||
|
$response->status = $resp['response']['code'];
|
||||||
|
$response->headers = $resp['headers'];
|
||||||
|
$response->results = $resp['body'];
|
||||||
|
|
||||||
@$client->fetch($url);
|
return $response;
|
||||||
return $client;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user