mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 07:00:01 +00: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 )
|
if ( false == $file_path )
|
||||||
return $headers;
|
return $headers;
|
||||||
|
|
||||||
// GET request - fetch and write it to the supplied filename
|
// GET request - write it to the supplied filename
|
||||||
$content_length = isset( $headers['content-length'] ) ? $headers['content-length'] : strlen( $response['body'] );
|
|
||||||
$got_bytes = 0;
|
|
||||||
$out_fp = fopen($file_path, 'w');
|
$out_fp = fopen($file_path, 'w');
|
||||||
while ( !feof($fp) ) {
|
if ( !$out_fp )
|
||||||
$buf = fread( $fp, 4096 );
|
return $headers;
|
||||||
fwrite( $out_fp, $buf );
|
|
||||||
$got_bytes += strlen($buf);
|
|
||||||
// don't read past the content-length
|
|
||||||
if ($content_length and $got_bytes >= $content_length)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
fwrite( $out_fp, $response['body']);
|
||||||
fclose($out_fp);
|
fclose($out_fp);
|
||||||
|
|
||||||
return $headers;
|
return $headers;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user