Merge branch 'MDL-42985-master' of git://github.com/FMCorz/moodle

This commit is contained in:
Damyon Wiese 2013-11-25 14:52:26 +08:00
commit a184b3d712
2 changed files with 27 additions and 3 deletions

View file

@ -3314,9 +3314,11 @@ class curl {
* @return bool
*/
protected function request($url, $options = array()) {
// create curl instance
$curl = curl_init($url);
$options['url'] = $url;
// Set the URL as a curl option.
$this->setopt(array('CURLOPT_URL' => $url));
// Create curl instance.
$curl = curl_init();
// Reset here so that the data is valid when result returned from cache.
$this->info = array();

View file

@ -375,6 +375,28 @@ class core_filelib_testcase extends advanced_testcase {
$this->assertSame(0, $curl->get_errno());
$this->assertSame(1, $curl->info['redirect_count']);
$this->assertSame('done', $contents);
$oldproxy = $CFG->proxyhost;
$oldproxybypass = $CFG->proxybypass;
// Test without proxy bypass and inaccessible proxy.
$CFG->proxyhost = 'i.do.not.exist';
$CFG->proxybypass = '';
$curl = new curl();
$contents = $curl->get($testhtml);
$this->assertNotEquals(0, $curl->get_errno());
$this->assertNotEquals('47250a973d1b88d9445f94db4ef2c97a', md5($contents));
// Test with proxy bypass.
$testhtmlhost = parse_url($testhtml, PHP_URL_HOST);
$CFG->proxybypass = $testhtmlhost;
$curl = new curl();
$contents = $curl->get($testhtml);
$this->assertSame(0, $curl->get_errno());
$this->assertSame('47250a973d1b88d9445f94db4ef2c97a', md5($contents));
$CFG->proxyhost = $oldproxy;
$CFG->proxybypass = $oldproxybypass;
}
/**