Merge branch '77137-proxybypass-on-multiple-curl-queries-main' of https://github.com/DSI-Universite-Rennes2/moodle
This commit is contained in:
@@ -3639,6 +3639,10 @@ class curl {
|
||||
$options[$n] = $v;
|
||||
}
|
||||
$handles[$i] = curl_init($requests[$i]['url']);
|
||||
|
||||
// Set the URL as a curl option.
|
||||
$this->setopt(['CURLOPT_URL' => $requests[$i]['url']]);
|
||||
|
||||
$this->apply_opt($handles[$i], $options);
|
||||
curl_multi_add_handle($main, $handles[$i]);
|
||||
}
|
||||
|
||||
@@ -511,6 +511,27 @@ final class filelib_test extends \advanced_testcase {
|
||||
$this->assertNotEquals(0, $curl->get_errno());
|
||||
$this->assertNotEquals('47250a973d1b88d9445f94db4ef2c97a', md5($contents));
|
||||
|
||||
// Test multiple queries with proxy.
|
||||
$curl = new \curl(['debug' => 1]);
|
||||
ob_start();
|
||||
$requests = [[
|
||||
'nobody' => true,
|
||||
'header' => 1,
|
||||
'url' => $testurl,
|
||||
'returntransfer' => true,
|
||||
],
|
||||
[
|
||||
'nobody' => true,
|
||||
'header' => 1,
|
||||
'url' => $testurl,
|
||||
'returntransfer' => true,
|
||||
]];
|
||||
$curl->download($requests);
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
// We must have exactly 2 occurrences of ["CURLOPT_PROXY"].
|
||||
$this->assertMatchesRegularExpression('/(\["CURLOPT_PROXY"\].*){2}/ms', $output);
|
||||
|
||||
// Test with proxy bypass.
|
||||
$testurlhost = parse_url($testurl, PHP_URL_HOST);
|
||||
$CFG->proxybypass = $testurlhost;
|
||||
@@ -519,6 +540,26 @@ final class filelib_test extends \advanced_testcase {
|
||||
$this->assertSame(0, $curl->get_errno());
|
||||
$this->assertSame('47250a973d1b88d9445f94db4ef2c97a', md5($contents));
|
||||
|
||||
// Test multiple queries with proxy bypass.
|
||||
$curl = new \curl(['debug' => 1]);
|
||||
ob_start();
|
||||
$requests = [[
|
||||
'nobody' => true,
|
||||
'header' => 1,
|
||||
'url' => $testurl,
|
||||
'returntransfer' => true,
|
||||
],
|
||||
[
|
||||
'nobody' => true,
|
||||
'header' => 1,
|
||||
'url' => $testurl,
|
||||
'returntransfer' => true,
|
||||
]];
|
||||
$curl->download($requests);
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertStringNotContainsString('["CURLOPT_PROXY"]', $output);
|
||||
|
||||
$CFG->proxyhost = $oldproxy;
|
||||
$CFG->proxybypass = $oldproxybypass;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user