summaryrefslogtreecommitdiff
path: root/inc/IXR_Library.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2008-02-27 22:54:08 +0100
committerAndreas Gohr <andi@splitbrain.org>2008-02-27 22:54:08 +0100
commit059c03b9d791c26ea3cff32f6aed5c046d2640cc (patch)
treee34b79dafa11406539bb8227751e6d48c5989d59 /inc/IXR_Library.php
parentfdd2e9d64295969d5945f11cb7d457aa599a028f (diff)
downloadrpg-059c03b9d791c26ea3cff32f6aed5c046d2640cc.tar.gz
rpg-059c03b9d791c26ea3cff32f6aed5c046d2640cc.tar.bz2
use DokuHTTPClient in XMLRPC library
The code should work but is completely untested because it is currently not used. darcs-hash:20080227215408-7ad00-952ebba433991bde0c4282beeb4887c637eb25aa.gz
Diffstat (limited to 'inc/IXR_Library.php')
-rw-r--r--inc/IXR_Library.php94
1 files changed, 27 insertions, 67 deletions
diff --git a/inc/IXR_Library.php b/inc/IXR_Library.php
index 5a4859813..e46ebb20a 100644
--- a/inc/IXR_Library.php
+++ b/inc/IXR_Library.php
@@ -470,83 +470,43 @@ EOD;
}
}
-# FIXME use DokuHTTPClient here
-class IXR_Client {
- var $server;
- var $port;
- var $path;
- var $useragent;
- var $response;
+/**
+ * Changed for DokuWiki to use DokuHTTPClient
+ *
+ * This should be compatible to the original class, but uses DokuWiki's
+ * HTTP client library which will respect proxy settings
+ *
+ * Because the XMLRPC client is not used in DokuWiki currently this is completely
+ * untested
+ */
+class IXR_Client extends DokuHTTPClient {
+ var $posturl = '';
var $message = false;
- var $debug = false;
- // Storage place for an error message
- var $error = false;
+ var $xmlerror = false;
+
function IXR_Client($server, $path = false, $port = 80) {
if (!$path) {
// Assume we have been given a URL instead
- $bits = parse_url($server);
- $this->server = $bits['host'];
- $this->port = isset($bits['port']) ? $bits['port'] : 80;
- $this->path = isset($bits['path']) ? $bits['path'] : '/';
- // Make absolutely sure we have a path
- if (!$this->path) {
- $this->path = '/';
- }
- } else {
- $this->server = $server;
- $this->path = $path;
- $this->port = $port;
+ $this->posturl = $server;
+ }else{
+ $this->posturl = 'http://'.$server.':'.$port.$path;
}
- $this->useragent = 'The Incutio XML-RPC PHP Library';
}
+
function query() {
$args = func_get_args();
$method = array_shift($args);
$request = new IXR_Request($method, $args);
- $length = $request->getLength();
$xml = $request->getXml();
- $r = "\r\n";
- $request = "POST {$this->path} HTTP/1.0$r";
- $request .= "Host: {$this->server}$r";
- $request .= "Content-Type: text/xml$r";
- $request .= "User-Agent: {$this->useragent}$r";
- $request .= "Content-length: {$length}$r$r";
- $request .= $xml;
- // Now send the request
- if ($this->debug) {
- echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n";
- }
- $fp = @fsockopen($this->server, $this->port);
- if (!$fp) {
- $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
+
+ $this->$headers['Content-Type'] = 'text/xml';
+ if(!$this->sendRequest($this->posturl,$xml,'RAW')){
+ $this->xmlerror = new IXR_Error(-32300, 'transport error - '.$this->error);
return false;
}
- fputs($fp, $request);
- $contents = '';
- $gotFirstLine = false;
- $gettingHeaders = true;
- while (!feof($fp)) {
- $line = fgets($fp, 4096);
- if (!$gotFirstLine) {
- // Check line for '200'
- if (strstr($line, '200') === false) {
- $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
- return false;
- }
- $gotFirstLine = true;
- }
- if (trim($line) == '') {
- $gettingHeaders = false;
- }
- if (!$gettingHeaders) {
- $contents .= trim($line)."\n";
- }
- }
- if ($this->debug) {
- echo '<pre>'.htmlspecialchars($contents)."\n</pre>\n\n";
- }
+
// Now parse what we've got back
- $this->message = new IXR_Message($contents);
+ $this->message = new IXR_Message($this->resp_body);
if (!$this->message->parse()) {
// XML error
$this->error = new IXR_Error(-32700, 'parse error. not well formed');
@@ -565,13 +525,13 @@ class IXR_Client {
return $this->message->params[0];
}
function isError() {
- return (is_object($this->error));
+ return (is_object($this->xmlerror));
}
function getErrorCode() {
- return $this->error->code;
+ return $this->xmlerror->code;
}
function getErrorMessage() {
- return $this->error->message;
+ return $this->xmlerror->message;
}
}
@@ -812,7 +772,7 @@ class IXR_ClientMulticall extends IXR_Client {
var $calls = array();
function IXR_ClientMulticall($server, $path = false, $port = 80) {
parent::IXR_Client($server, $path, $port);
- $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
+ //$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
}
function addCall() {
$args = func_get_args();