From 246e63053d5a04be443015d71a52181da80054ac Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 15 Jan 2007 08:01:35 +0000 Subject: [PATCH] - improve handling of xmlrpc request/response options --- lib/XmlRpcClient.php | 13 ++++++++++--- lib/XmlRpcServer.php | 14 ++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/XmlRpcClient.php b/lib/XmlRpcClient.php index 488e1cf..8668291 100644 --- a/lib/XmlRpcClient.php +++ b/lib/XmlRpcClient.php @@ -47,6 +47,13 @@ class XmlRpcClient */ public $__encoding = "iso-8859-1"; + /** + * RPC options + * + * @var array + */ + public $__options; + /** * Constructor * @@ -54,9 +61,9 @@ class XmlRpcClient * @param string $namespace RPC namespace * @param array $options HttpRequest options */ - public function __construct($url, $namespace = '', array $options = array()) + public function __construct($url, $namespace = '', array $options = null) { - $this->__request = new HttpRequest($url, HttpRequest::METH_POST, $options); + $this->__request = new HttpRequest($url, HttpRequest::METH_POST, (array) $options); $this->__namespace = $namespace; } @@ -76,7 +83,7 @@ class XmlRpcClient $this->__request->setContentType("text/xml"); $this->__request->setRawPostData( xmlrpc_encode_request($method, $params, - array("encoding" => $this->__encoding))); + array("encoding" => $this->__encoding) + (array) $this->__options)); $response = $this->__request->send(); if ($response->getResponseCode() != 200) { throw new Exception( diff --git a/lib/XmlRpcServer.php b/lib/XmlRpcServer.php index a9f7505..c8c1ac4 100644 --- a/lib/XmlRpcServer.php +++ b/lib/XmlRpcServer.php @@ -110,12 +110,13 @@ class XmlRpcServer extends HttpResponse * * @param string $method * @param array $params - * @param array $options + * @param array $request_options + * @param array $response_options */ - public static function test($method, array $params, array $options = null) + public static function test($method, array $params, array $request_options = null, array $response_options = null) { - self::$xmlreq = xmlrpc_encode_request($method, $params); - self::run(); + self::$xmlreq = xmlrpc_encode_request($method, $params, $request_options); + self::run($response_options); } /** @@ -124,9 +125,10 @@ class XmlRpcServer extends HttpResponse * @param int $code * @param string $msg */ - public static function error($code, $msg) + public static function error($code, $msg, array $options = null) { - echo xmlrpc_encode(array("faultCode" => $code, "faultString" => $msg)); + echo xmlrpc_encode(array("faultCode" => $code, "faultString" => $msg), + array("encoding" => self::$encoding) + (array) $options); } /** -- 2.30.2