Allow for the callee of download_url() to specify a different timeout if they want to - maybe they don't want to wait that long.

git-svn-id: http://svn.automattic.com/wordpress/trunk@16763 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2010-12-07 12:45:24 +00:00
parent 26d7de2d93
commit 1bb4914c3a
1 changed files with 3 additions and 2 deletions

View File

@ -507,9 +507,10 @@ function wp_handle_sideload( &$file, $overrides = false ) {
* @since 2.5.0
*
* @param string $url the URL of the file to download
* @param int $timeout The timeout for the request to download the file default 300 seconds
* @return mixed WP_Error on failure, string Filename on success.
*/
function download_url( $url ) {
function download_url( $url, $timeout = 300 ) {
//WARNING: The file is not automatically deleted, The script must unlink() the file.
if ( ! $url )
return new WP_Error('http_no_url', __('Invalid URL Provided.'));
@ -522,7 +523,7 @@ function download_url( $url ) {
if ( ! $handle )
return new WP_Error('http_no_file', __('Could not create Temporary file.'));
$response = wp_remote_get($url, array('timeout' => 300));
$response = wp_remote_get($url, array('timeout' => $timeout));
if ( is_wp_error($response) ) {
fclose($handle);