Make WordPress Core

Changeset 13151


Ignore:
Timestamp:
02/14/2010 11:23:32 AM (16 years ago)
Author:
dd32
Message:

Update wp_get_http() to handle redirections on HEAD requests. Un-deprecate $red header to track total redirections. See #10624

File:
1 edited

Legend:

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

    r13148 r13151  
    12371237 * @param string $url URL to fetch.
    12381238 * @param string|bool $file_path Optional. File path to write request to.
    1239  * @param bool $deprecated Deprecated. Not used.
     1239 * @param int $red (private) The number of Redirects followed, Upon 5 being hit, returns false.
    12401240 * @return bool|string False on failure and string of headers if HEAD request.
    12411241 */
    1242 function wp_get_http( $url, $file_path = false, $deprecated = false ) {
    1243     if ( !empty( $deprecated ) )
    1244         _deprecated_argument( __FUNCTION__, '2.7' );
    1245 
     1242function wp_get_http( $url, $file_path = false, $red = 1 ) {
    12461243    @set_time_limit( 60 );
     1244
     1245    if ( $red > 5 )
     1246        return false;
    12471247
    12481248    $options = array();
     
    12611261    $headers = wp_remote_retrieve_headers( $response );
    12621262    $headers['response'] = $response['response']['code'];
     1263
     1264    // WP_HTTP no longer follows redirects for HEAD requests.
     1265    if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) {
     1266        return wp_get_http( $headers['location'], $file_path, ++$red );
     1267    }
    12631268
    12641269    if ( false == $file_path )
Note: See TracChangeset for help on using the changeset viewer.