From 02db0d1325bf3ef7914e341011dafd317c7b0957 Mon Sep 17 00:00:00 2001 From: gggeek Date: Sun, 8 Jan 2023 14:12:26 +0000 Subject: [PATCH] more demo improvements --- demo/client/introspect.php | 4 ++-- demo/client/which.php | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/demo/client/introspect.php b/demo/client/introspect.php index 30a0a62e..683ad907 100644 --- a/demo/client/introspect.php +++ b/demo/client/introspect.php @@ -11,7 +11,7 @@ output(' '); 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("

methods available at http://" . $client->server . $client->path . "

\n"); diff --git a/demo/client/which.php b/demo/client/which.php index 1de3207f..b3b93e32 100644 --- a/demo/client/which.php +++ b/demo/client/which.php @@ -6,29 +6,34 @@ output('

Which toolkit demo

Query server for toolkit information

-

The code demonstrates support for http redirects, the `interopEchoTests.whichToolkit` xml-rpc methods and use of pre-built xml

+

The code demonstrates support for http redirects, the `interopEchoTests.whichToolkit` xml-rpc methods, request compression and use of pre-built xml

You can see the source to this page here: which.php

'); 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 = ' interopEchoTests.whichToolkit '; -// and ask the client to give us back xml +output("XML custom request:
" . htmlspecialchars($payload) . "
\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:
" . htmlspecialchars($payload) . "
\n"); +$client->setDebug(1); $resp = $client->send($payload); -- 2.47.0