From 6ada877b7ff60bad6818c0707bc7e44facc94755 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 5 Apr 2021 11:31:51 +0200 Subject: [PATCH] test --- test/debug.php | 17 +++++++++++++++++ test/debug.py | 14 ++++++++++++++ test/index.cgi | 15 +++++++++++++++ test/web.php | 18 ++++++++++++++++++ test/web.py | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+) create mode 100755 test/debug.php create mode 100755 test/debug.py create mode 100755 test/index.cgi create mode 100644 test/web.php create mode 100644 test/web.py diff --git a/test/debug.php b/test/debug.php new file mode 100755 index 0000000..574ba86 --- /dev/null +++ b/test/debug.php @@ -0,0 +1,17 @@ +PHP'); + +echo('

getenv()

'); +echo(''); +foreach (getenv() as $k => $v) + echo(""); +echo('
$k$v
'); + +echo(getcwd()); + +echo('
'); + +require(dirname(__FILE__).'/web.php'); + +?> diff --git a/test/debug.py b/test/debug.py new file mode 100755 index 0000000..e15865a --- /dev/null +++ b/test/debug.py @@ -0,0 +1,14 @@ +#! /usr/bin/env python3 + +import web + + +web.print_headers_if_needed() + +print('

Python

') + +print('

os.environ

') +web.print_environment() + +print('

variables

') +web.print_variables() diff --git a/test/index.cgi b/test/index.cgi new file mode 100755 index 0000000..79d83db --- /dev/null +++ b/test/index.cgi @@ -0,0 +1,15 @@ +#! /usr/bin/env python3 + +from waitress import serve + + +def app(): + import web + web.print_headers_if_needed() + counter += 1 + print('Counter: {}'.format(counter)) + + +if __name__ == '__main__': + counter = 0 + serve(app, unix_socket='/var/run/fcgiwrap.socket') diff --git a/test/web.php b/test/web.php new file mode 100644 index 0000000..0e2e32a --- /dev/null +++ b/test/web.php @@ -0,0 +1,18 @@ + diff --git a/test/web.py b/test/web.py new file mode 100644 index 0000000..795f058 --- /dev/null +++ b/test/web.py @@ -0,0 +1,36 @@ +import os + +VARIABLES = [ + 'REMOTE_ADDR', + 'SERVER_ADDR', + 'HTTPS', + 'REQUEST_SCHEME', + 'HTTP_HOST', + 'SERVER_NAME', + 'SCRIPT_NAME', + 'QUERY_STRING', +] + + +def print_headers_if_needed(): + if not os.environ['SCRIPT_NAME'].endswith('.php'): + print('Content-Type: text/html;charset=UTF-8') + print() + + +def print_environment(): + print('') + for key, value in sorted(os.environ.items()): + print(''' + +'''.format(key, value)) + print('
{}{}
') + + +def print_variables(): + print('') + for v in VARIABLES: + print(''' + +'''.format(v, os.environ[v])) + print('
{}{}
')