WordPress.org

Make WordPress Core

Changeset 9553


Ignore:
Timestamp:
11/06/08 19:06:43 (6 years ago)
Author:
ryan
Message:

Port Magpie from Snoopy to WP HTTP Request API. fixes #8082

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/rss.php

    r9243 r9553  
    385385 
    386386} 
    387 require_once( dirname(__FILE__) . '/class-snoopy.php'); 
    388387 
    389388if ( !function_exists('fetch_rss') ) : 
     
    527526 
    528527/** 
    529  * Retrieve URL headers and content using Snoopy. 
     528 * Retrieve URL headers and content using WP HTTP Request API. 
    530529 * 
    531530 * @since unknown 
     
    535534 * @param string $url URL to retrieve 
    536535 * @param array $headers Optional. Headers to send to the URL. 
    537  * @return Snoopy 
     536 * @return Snoopy style response 
    538537 */ 
    539538function _fetch_remote_file ($url, $headers = "" ) { 
    540     // Snoopy is an HTTP client in PHP 
    541     $client = new Snoopy(); 
    542     $client->agent = apply_filters( 'magpie_user_agent', MAGPIE_USER_AGENT ); 
    543     $client->read_timeout = MAGPIE_FETCH_TIME_OUT; 
    544     $client->use_gzip = MAGPIE_USE_GZIP; 
    545     if (is_array($headers) ) { 
    546         $client->rawheaders = $headers; 
    547     } 
    548  
    549     @$client->fetch($url); 
    550     return $client; 
    551  
     539    $resp = wp_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT)); 
     540    if ( is_wp_error($resp) ) { 
     541        $resp = new stdClass; 
     542        $resp->status = 500; 
     543        return $resp; 
     544    } 
     545    $response->status = $resp['response']['code']; 
     546    $response->headers = $resp['headers']; 
     547    $response->results = $resp['body']; 
     548 
     549    return $response; 
    552550} 
    553551 
Note: See TracChangeset for help on using the changeset viewer.