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
24 public static function getArgs()
26 /// @todo should we prefix all test parameters with TESTS_ ?
29 'HTTPSERVER' => 'localhost',
31 // now that we run tests in Docker by default, with a webserver set up for https, let's default to it
32 'HTTPSSERVER' => 'localhost',
34 // example alternative:
35 //'HTTPSSERVER' => 'gggeek.altervista.org',
36 //'HTTPSURI' => '/sw/xmlrpc/demo/server/server.php',
37 'HTTPSIGNOREPEER' => false,
38 'HTTPSVERIFYHOST' => 2,
40 'PROXYSERVER' => null,
41 //'LOCALPATH' => __DIR__,
44 // check for command line (env vars) vs. web page input params
45 if (!isset($_SERVER['REQUEST_METHOD'])) {
46 foreach($_SERVER as $key => $val) {
47 if (array_key_exists($key, $args)) {
52 // NB: we might as well consider using $_GET stuff later on...
58 $args['DEBUG'] = intval($DEBUG);
61 if (isset($HTTPSERVER)) {
62 $args['HTTPSERVER'] = $HTTPSERVER;
64 if (isset($HTTP_HOST)) {
65 $args['HTTPSERVER'] = $HTTP_HOST;
66 } elseif (isset($_SERVER['HTTP_HOST'])) {
67 $args['HTTPSERVER'] = $_SERVER['HTTP_HOST'];
71 if (!isset($HTTPURI) || $HTTPURI == '') {
72 // GUESTIMATE the url of local demo server
73 // play nice to php 3 and 4-5 in retrieving URL of server.php
74 /// @todo filter out query string from REQUEST_URI
75 if (isset($REQUEST_URI)) {
76 $HTTPURI = str_replace('/tests/testsuite.php', '/demo/server/server.php', $REQUEST_URI);
77 $HTTPURI = str_replace('/testsuite.php', '/server.php', $HTTPURI);
78 $HTTPURI = str_replace('/tests/benchmark.php', '/demo/server/server.php', $HTTPURI);
79 $HTTPURI = str_replace('/benchmark.php', '/server.php', $HTTPURI);
80 } elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['REQUEST_METHOD'])) {
81 $HTTPURI = str_replace('/tests/testsuite.php', '/demo/server/server.php', $_SERVER['PHP_SELF']);
82 $HTTPURI = str_replace('/testsuite.php', '/server.php', $HTTPURI);
83 $HTTPURI = str_replace('/tests/benchmark.php', '/demo/server/server.php', $HTTPURI);
84 $HTTPURI = str_replace('/benchmark.php', '/server.php', $HTTPURI);
86 $HTTPURI = '/demo/server/server.php';
89 if ($HTTPURI[0] != '/') {
90 $HTTPURI = '/' . $HTTPURI;
92 $args['HTTPURI'] = $HTTPURI;
94 if (isset($HTTPSSERVER)) {
95 $args['HTTPSSERVER'] = $HTTPSSERVER;
98 /// @todo if $HTTPSURI is unset, and HTTPSSERVER == localhost, use HTTPURI
99 if (isset($HTTPSURI)) {
100 $args['HTTPSURI'] = $HTTPSURI;
103 if (isset($HTTPSIGNOREPEER)) {
104 $args['HTTPSIGNOREPEER'] = (bool)$HTTPSIGNOREPEER;
107 if (isset($HTTPSVERIFYHOST)) {
108 $args['HTTPSVERIFYHOST'] = (int)$HTTPSVERIFYHOST;
111 if (isset($SSLVERSION)) {
112 $args['SSLVERSION'] = (int)$SSLVERSION;
115 if (isset($PROXYSERVER)) {
116 $arr = explode(':', $PROXYSERVER);
117 $args['PROXYSERVER'] = $arr[0];
118 if (count($arr) > 1) {
119 $args['PROXYPORT'] = $arr[1];
121 $args['PROXYPORT'] = 8080;
125 //if (isset($LOCALPATH)) {
126 // $args['LOCALPATH'] = $LOCALPATH;