WordPress.org

Make WordPress Core

Changeset 13848


Ignore:
Timestamp:
03/28/2010 12:33:25 AM (8 years ago)
Author:
dd32
Message:

Fix WP_HTTP -> Snoopy Compat layer for Magpie RSS. Fixes #12045

File:
1 edited

Legend:

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

    r13725 r13848  
    541541 * @return Snoopy style response
    542542 */
    543 function _fetch_remote_file ($url, $headers = "" ) {
     543function _fetch_remote_file($url, $headers = "" ) {
    544544    $resp = wp_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT));
    545545    if ( is_wp_error($resp) ) {
     
    552552        return $resp;
    553553    }
     554
     555    // Snoopy returns headers unprocessed.
     556    // Also note, WP_HTTP lowercases all keys, Snoopy did not.
     557    $return_headers = array();
     558    foreach ( $resp['headers'] as $key => $value ) {
     559        if ( !is_array($value) ) {
     560            $return_headers[] = "$key: $value";
     561        } else {
     562            foreach ( $value as $v )
     563                $return_headers[] = "$key: $v";
     564        }
     565    }
     566
    554567    $response = new stdClass;
    555568    $response->status = $resp['response']['code'];
    556569    $response->response_code = $resp['response']['code'];
    557     $response->headers = $resp['headers'];
     570    $response->headers = $return_headers;
    558571    $response->results = $resp['body'];
    559572
     
    588601            }
    589602
    590             if ( $field == 'ETag' ) {
     603            if ( $field == 'etag' ) {
    591604                $rss->etag = $val;
    592605            }
    593606
    594             if ( $field == 'Last-Modified' ) {
     607            if ( $field == 'last-modified' ) {
    595608                $rss->last_modified = $val;
    596609            }
Note: See TracChangeset for help on using the changeset viewer.