more demo improvements
authorgggeek <giunta.gaetano@gmail.com>
Sun, 8 Jan 2023 14:12:26 +0000 (14:12 +0000)
committergggeek <giunta.gaetano@gmail.com>
Sun, 8 Jan 2023 14:12:26 +0000 (14:12 +0000)
demo/client/introspect.php
demo/client/which.php

index 30a0a62..683ad90 100644 (file)
@@ -11,7 +11,7 @@ output('<html lang="en">
 ');
 
 use PhpXmlRpc\Client;
-use PhpXmlRpc\Helper\XMLParser;
+use PhpXmlRpc\Helper\XMLParser as XMLRPCParser;
 use PhpXmlRpc\Request;
 
 function display_error($r)
@@ -22,7 +22,7 @@ function display_error($r)
 
 $client = new Client(XMLRPCSERVER);
 // tell the client we want back plain php values
-$client->return_type = XMLParser::RETURN_PHP;
+$client->return_type = XMLRPCParser::RETURN_PHP;
 
 // First off, let's retrieve the list of methods available on the remote server
 output("<h3>methods available at http://" . $client->server . $client->path . "</h3>\n");
index 1de3207..b3b93e3 100644 (file)
@@ -6,29 +6,34 @@ output('<html lang="en">
 <body>
 <h1>Which toolkit demo</h1>
 <h2>Query server for toolkit information</h2>
-<h3>The code demonstrates support for http redirects, the `interopEchoTests.whichToolkit` xml-rpc methods and use of pre-built xml</h3>
+<h3>The code demonstrates support for http redirects, the `interopEchoTests.whichToolkit` xml-rpc methods, request compression and use of pre-built xml</h3>
 <p>You can see the source to this page here: <a href="which.php?showSource=1">which.php</a></p>
 ');
 
 use PhpXmlRpc\Client;
 use PhpXmlRpc\Encoder;
 
-$client = new Client(XMLRPCSERVER);
-
-// to support http redirects we have to force usage of cURL even for http 1.0 requests
-$client->setUseCurl(Client::USE_CURL_ALWAYS);
-$client->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => true, CURLOPT_POSTREDIR => 3));
-
 // use a pre-built request payload
 $payload = '<?xml version="1.0"?>
 <methodCall>
     <methodName>interopEchoTests.whichToolkit</methodName>
     <params/>
 </methodCall>';
-// and ask the client to give us back xml
+output("XML custom request:<br/><pre>" . htmlspecialchars($payload) . "</pre>\n");
+
+$client = new Client(XMLRPCSERVER);
+
+// to support http redirects we have to force usage of cURL even for http 1.0 requests
+$client->setUseCurl(Client::USE_CURL_ALWAYS);
+$client->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => true, CURLOPT_POSTREDIR => 3));
+
+// if we know that the server supports them, we can enable sending of compressed requests
+$client->setRequestCompression('gzip');
+
+// ask the client to give us back xml
 $client->return_type = 'xml';
 
-output("XML custom request:<br/><pre>" . htmlspecialchars($payload) . "</pre>\n");
+$client->setDebug(1);
 
 $resp = $client->send($payload);