From 0155abf5859f57edc1144dd3e42671d16d02982e Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 6 Nov 2008 19:06:43 +0000 Subject: [PATCH] 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 --- wp-includes/rss.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/wp-includes/rss.php b/wp-includes/rss.php index 60e1b759a..9ab7d53a0 100644 --- a/wp-includes/rss.php +++ b/wp-includes/rss.php @@ -384,7 +384,6 @@ class MagpieRSS { } } -require_once( dirname(__FILE__) . '/class-snoopy.php'); if ( !function_exists('fetch_rss') ) : /** @@ -526,7 +525,7 @@ function fetch_rss ($url) { endif; /** - * Retrieve URL headers and content using Snoopy. + * Retrieve URL headers and content using WP HTTP Request API. * * @since unknown * @package External @@ -534,21 +533,20 @@ endif; * * @param string $url URL to retrieve * @param array $headers Optional. Headers to send to the URL. - * @return Snoopy + * @return Snoopy style response */ function _fetch_remote_file ($url, $headers = "" ) { - // Snoopy is an HTTP client in PHP - $client = new Snoopy(); - $client->agent = apply_filters( 'magpie_user_agent', MAGPIE_USER_AGENT ); - $client->read_timeout = MAGPIE_FETCH_TIME_OUT; - $client->use_gzip = MAGPIE_USE_GZIP; - if (is_array($headers) ) { - $client->rawheaders = $headers; + $resp = wp_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT)); + if ( is_wp_error($resp) ) { + $resp = new stdClass; + $resp->status = 500; + return $resp; } + $response->status = $resp['response']['code']; + $response->headers = $resp['headers']; + $response->results = $resp['body']; - @$client->fetch($url); - return $client; - + return $response; } /**