wp_get_http() fixes. see #7944

git-svn-id: http://svn.automattic.com/wordpress/trunk@9301 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-10-23 19:39:17 +00:00
parent f275541cf6
commit 77f5447071
1 changed files with 4 additions and 11 deletions

View File

@ -1054,19 +1054,12 @@ function wp_get_http( $url, $file_path = false, $deprecated = false ) {
if ( false == $file_path )
return $headers;
// GET request - fetch and write it to the supplied filename
$content_length = isset( $headers['content-length'] ) ? $headers['content-length'] : strlen( $response['body'] );
$got_bytes = 0;
// GET request - write it to the supplied filename
$out_fp = fopen($file_path, 'w');
while ( !feof($fp) ) {
$buf = fread( $fp, 4096 );
fwrite( $out_fp, $buf );
$got_bytes += strlen($buf);
// don't read past the content-length
if ($content_length and $got_bytes >= $content_length)
break;
}
if ( !$out_fp )
return $headers;
fwrite( $out_fp, $response['body']);
fclose($out_fp);
return $headers;