Index: lib/filelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/filelib.php,v retrieving revision 1.50.2.9 diff -u -r1.50.2.9 filelib.php --- lib/filelib.php 17 Mar 2008 12:35:35 -0000 1.50.2.9 +++ lib/filelib.php 25 Mar 2008 15:19:00 -0000 @@ -10,10 +10,14 @@ * @param array $headers http headers, null if none * @param array $postdata array means use POST request with given parameters * @param bool $fullresponse return headers, responses, etc in a similar way snoopy does - * @param int $timeout connection timeout + * @param int $timeout timeout for complete download process including all file transfer + * (default 5 minutes) + * @param int $connecttimeout timeout for connection to server; this is the timeout that + * usually happens if the remote server is completely down (default 20 seconds); + * may not work when using proxy * @return mixed false if request failed or content of the file as string if ok. */ -function download_file_content($url, $headers=null, $postdata=null, $fullresponse=false, $timeout=20) { +function download_file_content($url, $headers=null, $postdata=null, $fullresponse=false, $timeout=300, $connecttimeout=20) { global $CFG; // some extra security @@ -43,6 +47,7 @@ require_once($CFG->libdir.'/snoopy/Snoopy.class.inc'); $snoopy = new Snoopy(); $snoopy->read_timeout = $timeout; + $snoopy->_fp_timeout = $connecttimeout; $snoopy->proxy_host = $CFG->proxyhost; $snoopy->proxy_port = $CFG->proxyport; if (!empty($CFG->proxyuser) and !empty($CFG->proxypassword)) { @@ -118,7 +123,8 @@ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connecttimeout); + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); if (!ini_get('open_basedir') and !ini_get('safe_mode')) { // TODO: add version test for '7.10.5' curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);