4 * Common parameter parsing for benchmark and tests scripts.
7 * @param string HTTPSERVER
8 * @param string HTTPURI
9 * @param string HTTPSSERVER
10 * @param string HTTPSURI
11 * @param bool HTTPSIGNOREPEER
12 * @param int HTTPSVERIFYHOST
13 * @param int SSLVERSION
14 * @param string PROXYSERVER
16 * @copyright (C) 2007-2020 G. Giunta
17 * @license code licensed under the BSD License: see file license.txt
19 * @todo rename both the class and the file. PhpXmlRpc_TestArgParser ?
26 public static function getArgs()
28 /// @todo should we prefix all test parameters with TESTS_ ?
31 'HTTPSERVER' => 'localhost',
33 // now that we run tests in Docker by default, with a webserver set up for https, let's default to it
34 'HTTPSSERVER' => 'localhost',
36 // example alternative:
37 //'HTTPSSERVER' => 'gggeek.altervista.org',
38 //'HTTPSURI' => '/sw/xmlrpc/demo/server/server.php',
39 'HTTPSIGNOREPEER' => false,
40 'HTTPSVERIFYHOST' => 2,
42 'PROXYSERVER' => null,
43 //'LOCALPATH' => __DIR__,
46 // check for command line (env vars) vs. web page input params
47 if (!isset($_SERVER['REQUEST_METHOD'])) {
48 foreach($_SERVER as $key => $val) {
49 if (array_key_exists($key, $args)) {
54 // NB: we might as well consider using $_GET stuff later on...
60 $args['DEBUG'] = intval($DEBUG);
63 if (isset($HTTPSERVER)) {
64 $args['HTTPSERVER'] = $HTTPSERVER;
66 if (isset($HTTP_HOST)) {
67 $args['HTTPSERVER'] = $HTTP_HOST;
68 } elseif (isset($_SERVER['HTTP_HOST'])) {
69 $args['HTTPSERVER'] = $_SERVER['HTTP_HOST'];
73 if (!isset($HTTPURI) || $HTTPURI == '') {
74 // GUESTIMATE the url of local demo server
75 // play nice to php 4 and 5 in retrieving URL of server.php
76 /// @todo filter out query string from REQUEST_URI
77 /// @todo review this code...
78 if (isset($REQUEST_URI)) {
79 $HTTPURI = str_replace('/tests/testsuite.php', '/demo/server/server.php', $REQUEST_URI);
80 $HTTPURI = str_replace('/testsuite.php', '/server.php', $HTTPURI);
81 $HTTPURI = str_replace('/extras/benchmark.php', '/demo/server/server.php', $HTTPURI);
82 $HTTPURI = str_replace('/benchmark.php', '/server.php', $HTTPURI);
83 } elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['REQUEST_METHOD'])) {
84 $HTTPURI = str_replace('/tests/testsuite.php', '/demo/server/server.php', $_SERVER['PHP_SELF']);
85 $HTTPURI = str_replace('/testsuite.php', '/server.php', $HTTPURI);
86 $HTTPURI = str_replace('/extras/benchmark.php', '/demo/server/server.php', $HTTPURI);
87 $HTTPURI = str_replace('/benchmark.php', '/server.php', $HTTPURI);
89 $HTTPURI = '/demo/server/server.php';
92 if ($HTTPURI[0] != '/') {
93 $HTTPURI = '/' . $HTTPURI;
95 $args['HTTPURI'] = $HTTPURI;
97 if (isset($HTTPSSERVER)) {
98 $args['HTTPSSERVER'] = $HTTPSSERVER;
101 /// @todo if $HTTPSURI is unset, and HTTPSSERVER == localhost, use HTTPURI
102 if (isset($HTTPSURI)) {
103 $args['HTTPSURI'] = $HTTPSURI;
106 if (isset($HTTPSIGNOREPEER)) {
107 $args['HTTPSIGNOREPEER'] = (bool)$HTTPSIGNOREPEER;
110 if (isset($HTTPSVERIFYHOST)) {
111 $args['HTTPSVERIFYHOST'] = (int)$HTTPSVERIFYHOST;
114 if (isset($SSLVERSION)) {
115 $args['SSLVERSION'] = (int)$SSLVERSION;
118 if (isset($PROXYSERVER)) {
119 $arr = explode(':', $PROXYSERVER);
120 $args['PROXYSERVER'] = $arr[0];
121 if (count($arr) > 1) {
122 $args['PROXYPORT'] = $arr[1];
124 $args['PROXYPORT'] = 8080;
128 //if (isset($LOCALPATH)) {
129 // $args['LOCALPATH'] = $LOCALPATH;