X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fxmlrpc.inc;h=79dbafbc3b0646d3a103b9fcb5780cf7ebb2c6f7;hb=cc1e3919b9fe640926cb88670e2cc9fb63416148;hp=74c2c25ea739e77df240ef5788efdb1b2c82b694;hpb=8346dc34a350ab95630faac56fca3663a4b8e49b;p=plcapi.git diff --git a/lib/xmlrpc.inc b/lib/xmlrpc.inc index 74c2c25..79dbafb 100644 --- a/lib/xmlrpc.inc +++ b/lib/xmlrpc.inc @@ -226,6 +226,7 @@ // set to TRUE to enable encoding of php NULL values to instead of $GLOBALS['xmlrpc_null_apache_encoding']=false; + $GLOBALS['xmlrpc_null_apache_encoding_ns']='http://ws.apache.org/xmlrpc/namespaces/extensions'; // used to store state during parsing // quick explanation of components: @@ -707,6 +708,7 @@ $GLOBALS['_xh']['value'] = $curr_val['values']; $GLOBALS['_xh']['vt']=strtolower($name); if (isset($curr_val['php_class'])) + { $GLOBALS['_xh']['php_class'] = $curr_val['php_class']; } @@ -828,7 +830,7 @@ var $proxy_pass=''; var $proxy_authtype=1; var $cookies=array(); - var $extracurlopts=array(); + var $extracurlopts=array(); /** * List of http compression methods accepted by the client for responses. @@ -861,6 +863,10 @@ * valid strings are 'xmlrpcvals', 'phpvals' or 'xml' */ var $return_type = 'xmlrpcvals'; + /** + * Sent to servers in http headers + */ + var $user_agent; /** * @param string $path either the complete server URL or the PATH part of the xmlrc server URL, e.g. /xmlrpc/server.php @@ -933,6 +939,9 @@ // by default the xml parser can support these 3 charset encodings $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII'); + + // initialize user_agent string + $this->user_agent = $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion']; } /** @@ -981,6 +990,7 @@ function setCaCertificate($cacert, $is_dir=false) { if ($is_dir) + { $this->cacertdir = $cacert; } @@ -1055,7 +1065,10 @@ if ($compmethod == 'any') $this->accepted_compression = array('gzip', 'deflate'); else - $this->accepted_compression = array($compmethod); + if ($compmethod == false ) + $this->accepted_compression = array(); + else + $this->accepted_compression = array($compmethod); } /** @@ -1099,15 +1112,24 @@ } } - /** - * Directly set cURL options, for extra flexibility - * It allows eg. to bind client to a specific IP interface / address - * @param $options array - */ - function SetCurlOptions( $options ) - { - $this->extracurlopts = $options; - } + /** + * Directly set cURL options, for extra flexibility + * It allows eg. to bind client to a specific IP interface / address + * @param $options array + */ + function SetCurlOptions( $options ) + { + $this->extracurlopts = $options; + } + + /** + * Set user-agent string that will be used by this client instance + * in http headers sent to the server + */ + function SetUserAgent( $agentstring ) + { + $this->user_agent = $agentstring; + } /** * Send an xmlrpc request @@ -1143,6 +1165,7 @@ $msg->debug=$this->debug; if($method == 'https') + { $r =& $this->sendPayloadHTTPS( $msg, @@ -1326,9 +1349,12 @@ $cookieheader = 'Cookie:' . $version . substr($cookieheader, 0, -1) . "\r\n"; } + // omit port if 80 + $port = ($port == 80) ? '' : (':' . $port); + $op= 'POST ' . $uri. " HTTP/1.0\r\n" . - 'User-Agent: ' . $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion'] . "\r\n" . - 'Host: '. $server . ':' . $port . "\r\n" . + 'User-Agent: ' . $this->user_agent . "\r\n" . + 'Host: '. $server . $port . "\r\n" . $credentials . $proxy_credentials . $accepted_encoding . @@ -1510,7 +1536,7 @@ { curl_setopt($curl, CURLOPT_VERBOSE, 1); } - curl_setopt($curl, CURLOPT_USERAGENT, $GLOBALS['xmlrpcName'].' '.$GLOBALS['xmlrpcVersion']); + curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); // required for XMLRPC: post the data curl_setopt($curl, CURLOPT_POST, 1); // the data @@ -1651,7 +1677,14 @@ { print "
\n---CURL INFO---\n";
 				foreach(curl_getinfo($curl) as $name => $val)
-					 print $name . ': ' . htmlentities($val). "\n";
+				{
+					if (is_array($val))
+					{
+						$val = implode("\n", $val);
+					}
+					print $name . ': ' . htmlentities($val) . "\n";
+				}
+
 				print "---END---\n
"; } @@ -1831,6 +1864,7 @@ case 1: if(!isset($val[0])) { + return false; // Bad value } // Normal return value @@ -2023,7 +2057,14 @@ $this->content_type = 'text/xml; charset=' . $charset_encoding; else $this->content_type = 'text/xml'; - $result = "\n"; + if ($GLOBALS['xmlrpc_null_apache_encoding']) + { + $result = "\n"; + } + else + { + $result = "\n"; + } if($this->errno) { // G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients @@ -3300,7 +3341,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha $out = $xmlrpc_val->scalarval(); if (is_string($out)) { - $out= strtotime($out); + $out = strtotime($out); } if (is_int($out)) { @@ -3449,7 +3490,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha else { $arr = array(); - reset($php_val); + reset($php_val); while(list($k,$v) = each($php_val)) { $arr[$k] = php_xmlrpc_encode($v, $options); @@ -3483,6 +3524,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha $xmlrpc_val = new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']); } else + { $xmlrpc_val = new xmlrpcval(); } @@ -3684,6 +3726,7 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha } elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk)) { + return 'UTF-8'; }