From 08ec989fd0b4d4fa8d386fb1b77f8eafbc19ad83 Mon Sep 17 00:00:00 2001 From: poltawski Date: Fri, 19 Oct 2007 14:47:14 +0000 Subject: [PATCH] MDL-11840 - curl was set to use CONNECTs for all http requests. This is disallowed by most http proxies to prevent tunneling. Added some debugging in case of failure. Merged from MOODLE_19_STABLE --- lib/filelib.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/filelib.php b/lib/filelib.php index 059bab450f..36145b8ecf 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -16,7 +16,9 @@ function download_file_content($url) { curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); if (!empty($CFG->proxyhost)) { - curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true); + // don't CONNECT for non-https connections + curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, false); + if (empty($CFG->proxyport)) { curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost); } else { @@ -27,6 +29,12 @@ function download_file_content($url) { } } $result = curl_exec($ch); + + if (curl_errno($ch)) { + $curlerror = "CURL request for \"$url\" failed with: ". curl_error($ch); + debugging($curlerror, DEBUG_DEVELOPER); + } + curl_close($ch); return $result; } -- 2.39.5