welcome 2021
[plcapi.git] / demo / server / proxy.php
index 7f4d16c..7f7b7ab 100644 (file)
@@ -5,12 +5,11 @@
  * the originating server).
  *
  * @author Gaetano Giunta
- * @copyright (C) 2006-2019 G. Giunta
+ * @copyright (C) 2006-2021 G. Giunta
  * @license code licensed under the BSD License: see file license.txt
  */
 
-include_once __DIR__ . "/../../src/Autoloader.php";
-PhpXmlRpc\Autoloader::register();
+require_once __DIR__ . "/_prepend.php";
 
 /**
  * Forward an xmlrpc request to another server, and return to client the response received.
@@ -58,8 +57,8 @@ function forward_request($req)
 
     // build call for remote server
     /// @todo find a way to forward client info (such as IP) to server, either
-    /// - as xml comments in the payload, or
-    /// - using std http header conventions, such as X-forwarded-for...
+    ///       - as xml comments in the payload, or
+    ///       - using std http header conventions, such as X-forwarded-for...
     $reqMethod = $encoder->decode($req->getParam(1));
     $pars = $req->getParam(2);
     $req = new PhpXmlRpc\Request($reqMethod);
@@ -74,6 +73,8 @@ function forward_request($req)
 }
 
 // run the server
+// NB: take care not to output anything else after this call, as it will mess up the responses and it will be hard to
+// debug. In case you have to do so, at least re-emit a correct Content-Length http header (requires output buffering)
 $server = new PhpXmlRpc\Server(
     array(
         'xmlrpcproxy.call' => array(
@@ -86,3 +87,5 @@ $server = new PhpXmlRpc\Server(
         ),
     )
 );
+
+require_once __DIR__ . "/_append.php";