mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 00:16:46 +02:00
Merge branch 'MDL-42985-master' of git://github.com/FMCorz/moodle
This commit is contained in:
commit
a184b3d712
2 changed files with 27 additions and 3 deletions
|
@ -3314,9 +3314,11 @@ class curl {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function request($url, $options = array()) {
|
protected function request($url, $options = array()) {
|
||||||
// create curl instance
|
// Set the URL as a curl option.
|
||||||
$curl = curl_init($url);
|
$this->setopt(array('CURLOPT_URL' => $url));
|
||||||
$options['url'] = $url;
|
|
||||||
|
// Create curl instance.
|
||||||
|
$curl = curl_init();
|
||||||
|
|
||||||
// Reset here so that the data is valid when result returned from cache.
|
// Reset here so that the data is valid when result returned from cache.
|
||||||
$this->info = array();
|
$this->info = array();
|
||||||
|
|
|
@ -375,6 +375,28 @@ class core_filelib_testcase extends advanced_testcase {
|
||||||
$this->assertSame(0, $curl->get_errno());
|
$this->assertSame(0, $curl->get_errno());
|
||||||
$this->assertSame(1, $curl->info['redirect_count']);
|
$this->assertSame(1, $curl->info['redirect_count']);
|
||||||
$this->assertSame('done', $contents);
|
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue