diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:42:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:42:58 +0000 |
commit | 678fe256b3133f41132119e7ecd2f3ceae8b67e6 (patch) | |
tree | 5941bbb318e538945db26bbb1cbe3147cfd137c4 /test/modules/tls/htdocs/b.mod-tls.test | |
parent | Adding debian version 2.4.57-2. (diff) | |
download | apache2-678fe256b3133f41132119e7ecd2f3ceae8b67e6.tar.xz apache2-678fe256b3133f41132119e7ecd2f3ceae8b67e6.zip |
Merging upstream version 2.4.59.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/modules/tls/htdocs/b.mod-tls.test')
-rwxr-xr-x | test/modules/tls/htdocs/b.mod-tls.test/vars.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/test/modules/tls/htdocs/b.mod-tls.test/vars.py b/test/modules/tls/htdocs/b.mod-tls.test/vars.py index f41ec6a..bd520e2 100755 --- a/test/modules/tls/htdocs/b.mod-tls.test/vars.py +++ b/test/modules/tls/htdocs/b.mod-tls.test/vars.py @@ -1,21 +1,29 @@ #!/usr/bin/env python3 import json import os, sys -import multipart from urllib import parse +import multipart # https://github.com/andrew-d/python-multipart (`apt install python3-multipart`) def get_request_params(): oforms = {} + ofiles = {} if "REQUEST_URI" in os.environ: qforms = parse.parse_qs(parse.urlsplit(os.environ["REQUEST_URI"]).query) for name, values in qforms.items(): oforms[name] = values[0] - myenv = os.environ.copy() - myenv['wsgi.input'] = sys.stdin.buffer - mforms, ofiles = multipart.parse_form_data(environ=myenv) - for name, item in mforms.items(): - oforms[name] = item + if "HTTP_CONTENT_TYPE" in os.environ: + ctype = os.environ["HTTP_CONTENT_TYPE"] + if ctype == "application/x-www-form-urlencoded": + qforms = parse.parse_qs(parse.urlsplit(sys.stdin.read()).query) + for name, values in qforms.items(): + oforms[name] = values[0] + elif ctype.startswith("multipart/"): + def on_field(field): + oforms[field.field_name] = field.value + def on_file(file): + ofiles[field.field_name] = field.value + multipart.parse_form(headers={"Content-Type": ctype}, input_stream=sys.stdin.buffer, on_field=on_field, on_file=on_file) return oforms, ofiles |