- xmlrpcs.inc: add a new member var in server class to allow fine-tuning of the encod...
[plcapi.git] / lib / xmlrpc.inc
index 8974fb2..4ac287a 100644 (file)
                var $proxy_pass='';\r
                var $proxy_authtype=1;\r
                var $cookies=array();\r
+           var $extracurlopts=array();\r
+\r
                /**\r
                * List of http compression methods accepted by the client for responses.\r
                * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib\r
                                $this->accepted_compression = array('gzip', 'deflate');\r
                        }\r
 \r
-                       // keepalives: enabled by default ONLY for PHP >= 4.3.8\r
+                       // keepalives: enabled by default\r
                        $this->keepalive = true;\r
 \r
                        // by default the xml parser can support these 3 charset encodings\r
                        }\r
                }\r
 \r
+           /**\r
+           * Directly set cURL options, for extra flexibility\r
+           * It allows eg. to bind client to a specific IP interface / address\r
+           * @param $options array\r
+           */\r
+           function SetCurlOptions( $options )\r
+           {\r
+               $this->extracurlopts = $options;\r
+           }\r
+\r
                /**\r
                * Send an xmlrpc request\r
                * @param mixed $msg The message object, or an array of messages for using multicall, or the complete xml representation of a request\r
                                curl_setopt($curl, CURLOPT_COOKIE, substr($cookieheader, 0, -2));\r
                        }\r
 \r
+                   foreach ($this->extracurlopts as $opt => $val)\r
+                   {\r
+                       curl_setopt($curl, $opt, $val);\r
+                   }\r
+\r
                        $result = curl_exec($curl);\r
 \r
                        if ($this->debug > 1)\r
@@ -3377,7 +3394,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha
        * @param array $options can include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api'\r
        * @return xmlrpcval\r
        */\r
-       function &php_xmlrpc_encode($php_val, $options=array())\r
+       function php_xmlrpc_encode($php_val, $options=array())\r
        {\r
                $type = gettype($php_val);\r
                switch($type)\r
@@ -3411,7 +3428,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha
                                $ko = false;\r
                                foreach($php_val as $key => $val)\r
                                {\r
-                                       $arr[$key] =& php_xmlrpc_encode($val, $options);\r
+                                       $arr[$key] = php_xmlrpc_encode($val, $options);\r
                                        if(!$ko && $key !== $j)\r
                                        {\r
                                                $ko = true;\r
@@ -3439,6 +3456,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha
                                else\r
                                {\r
                                        $arr = array();\r
+                                   reset($php_val);\r
                                        while(list($k,$v) = each($php_val))\r
                                        {\r
                                                $arr[$k] = php_xmlrpc_encode($v, $options);\r