From 6e0401d61f48693c426dd8abd96c81b5c8e4f094 Mon Sep 17 00:00:00 2001 From: Rod Norfor Date: Wed, 10 Jun 2015 08:17:36 +0100 Subject: [PATCH] MDL-39353 xmlrpc: Add proxy support --- webservice/xmlrpc/lib.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/webservice/xmlrpc/lib.php b/webservice/xmlrpc/lib.php index 5b68fe253df..579735bc080 100644 --- a/webservice/xmlrpc/lib.php +++ b/webservice/xmlrpc/lib.php @@ -46,9 +46,22 @@ class webservice_xmlrpc_client extends Zend_XmlRpc_Client { * @param string $token the token used to do the web service call */ public function __construct($serverurl, $token) { + global $CFG; $this->serverurl = $serverurl; $serverurl = $serverurl . '?wstoken=' . $token; parent::__construct($serverurl); + if (!empty($CFG->proxyhost) && !is_proxybypass($serverurl)) { + $config = array( + 'adapter' => 'Zend_Http_Client_Adapter_Proxy', + 'proxy_host' => $CFG->proxyhost, + 'proxy_user' => !empty($CFG->proxyuser) ? $CFG->proxyuser : null, + 'proxy_pass' => !empty($CFG->proxypassword) ? $CFG->proxypassword : null + ); + if (!empty($CFG->proxyport)) { + $config['proxy_port'] = $CFG->proxyport; + } + $this->getHttpClient()->setConfig($config); + } } /**