Make WordPress Core

Changeset 2956


Ignore:
Timestamp:
10/19/2005 06:09:23 AM (20 years ago)
Author:
matt
Message:

Fix for header redirects - Hat tip: http://www.davidmeade.com/post/post.php?topicID=579

File:
1 edited

Legend:

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

    r2942 r2956  
    926926}
    927927
    928 function wp_get_http_headers( $url ) {
     928function wp_get_http_headers( $url, $red = 1 ) {
    929929    global $wp_version;
    930930    @set_time_limit( 60 );
     931
     932    if ( $red > 5 )
     933       return false;
     934
    931935    $parts = parse_url( $url );
    932936    $file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : '');
     
    952956        $headers["$key"] = $matches[2][$i];
    953957    }
     958
     959    $code = preg_replace('/.*?(\d{3}).*/i', '$1', $response);
     960   
     961    $headers['status_code'] = $code;
     962   
     963    if ( '302' == $code || '301' == $code )
     964        return wp_get_http_headers( $url, ++$red );
    954965
    955966    preg_match('/.*([0-9]{3}).*/', $response, $return);
Note: See TracChangeset for help on using the changeset viewer.