- Fixed build on php-trunk
[m6w6/ext-http] / lib / XmlRpcClient.php
index 83a154e933448a37883e4d5e1bf3ffbc32f63823..8668291bd0a31cb7566f5dad25bd2c026b4ff6c3 100644 (file)
@@ -22,7 +22,7 @@
  * @copyright   Michael Wallner, <mike@iworks.at>
  * @license     BSD, revised
  * @package     pecl/http
- * @version     $Revision$
+ * @version        $Revision$
  */
 class XmlRpcClient
 {
@@ -47,6 +47,13 @@ class XmlRpcClient
         */
        public $__encoding = "iso-8859-1";
        
+       /**
+        * RPC options
+        * 
+        * @var array
+        */
+       public $__options;
+       
        /**
         * Constructor
         *
@@ -56,8 +63,7 @@ class XmlRpcClient
         */
        public function __construct($url, $namespace = '', array $options = null)
        {
-               $this->__request = new HttpRequest($url, HTTP_METH_POST);
-               $this->__request->setOptions($options);
+               $this->__request = new HttpRequest($url, HttpRequest::METH_POST, (array) $options);
                $this->__namespace = $namespace;
        }
        
@@ -71,14 +77,14 @@ class XmlRpcClient
         */
        public function __call($method, array $params)
        {
-               if ($this->__namespace) {
+               if (strlen($this->__namespace)) {
                        $method = $this->__namespace .'.'. $method;
                }
-               $this->__request->setContentType("text/xml; charset=". $this->__encoding);
-               $request = xmlrpc_encode_request($method, $params, array("encoding" => $this->__encoding));
-               $this->__request->setRawPostData($request);
-               $this->__request->send();
-               $response = $this->__request->getResponseMessage();
+               $this->__request->setContentType("text/xml");
+               $this->__request->setRawPostData(
+                       xmlrpc_encode_request($method, $params, 
+                               array("encoding" => $this->__encoding) + (array) $this->__options));
+               $response = $this->__request->send();
                if ($response->getResponseCode() != 200) {
                        throw new Exception(
                                $response->getResponseStatus(),