Skip to content

Commit d7605dd

Browse files
committed
Fix for header redirects - Hat tip: http://www.davidmeade.com/post/post.php?topicID=579
git-svn-id: https://develop.svn.wordpress.org/trunk@2956 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 25458f9 commit d7605dd

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

wp-includes/functions.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,9 +925,13 @@ function do_enclose( $content, $post_ID ) {
925925
endforeach;
926926
}
927927

928-
function wp_get_http_headers( $url ) {
928+
function 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'] : '');
933937
$host = $parts['host'];
@@ -952,6 +956,13 @@ function wp_get_http_headers( $url ) {
952956
$headers["$key"] = $matches[2][$i];
953957
}
954958

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 );
965+
955966
preg_match('/.*([0-9]{3}).*/', $response, $return);
956967
$headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404
957968
return $headers;

0 commit comments

Comments
 (0)