git-svn-id: http://svn.automattic.com/wordpress/trunk@2956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2005-10-19 06:09:23 +00:00
parent ab8cf86716
commit 8c0dd12af3
1 changed files with 12 additions and 1 deletions

View File

@ -925,9 +925,13 @@ function do_enclose( $content, $post_ID ) {
endforeach; endforeach;
} }
function wp_get_http_headers( $url ) { function wp_get_http_headers( $url, $red = 1 ) {
global $wp_version; global $wp_version;
@set_time_limit( 60 ); @set_time_limit( 60 );
if ( $red > 5 )
return false;
$parts = parse_url( $url ); $parts = parse_url( $url );
$file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : ''); $file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : '');
$host = $parts['host']; $host = $parts['host'];
@ -952,6 +956,13 @@ function wp_get_http_headers( $url ) {
$headers["$key"] = $matches[2][$i]; $headers["$key"] = $matches[2][$i];
} }
$code = preg_replace('/.*?(\d{3}).*/i', '$1', $response);
$headers['status_code'] = $code;
if ( '302' == $code || '301' == $code )
return wp_get_http_headers( $url, ++$red );
preg_match('/.*([0-9]{3}).*/', $response, $return); preg_match('/.*([0-9]{3}).*/', $response, $return);
$headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404 $headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404
return $headers; return $headers;