MDL-42985 curl: Correctly apply rule proxybypass
This commit is contained in:
+5
-3
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user