mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-02 05:31:25 +01:00
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:
parent
f275541cf6
commit
77f5447071
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user