summaryrefslogtreecommitdiffstats
path: root/test/modules/http2/htdocs/cgi/mnot164.py
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2023-03-20 16:02:13 +0100
committerYann Ylavic <ylavic@apache.org>2023-03-20 16:02:13 +0100
commit62c5aeadd0099b9f5ff11f304eab81ecd6d6b04f (patch)
treed6026e681614dc3d97447d55bb98e14a167fe0f8 /test/modules/http2/htdocs/cgi/mnot164.py
parentci: Disable MOD_TLS test suite for now (never passing). (diff)
downloadapache2-62c5aeadd0099b9f5ff11f304eab81ecd6d6b04f.tar.xz
apache2-62c5aeadd0099b9f5ff11f304eab81ecd6d6b04f.zip
pytests: Use python3-multipart lib.
Use the API of https://github.com/andrew-d/python-multipart, available as package python3-multipart on Debian/Ubuntu. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908574 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/modules/http2/htdocs/cgi/mnot164.py')
-rw-r--r--test/modules/http2/htdocs/cgi/mnot164.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/test/modules/http2/htdocs/cgi/mnot164.py b/test/modules/http2/htdocs/cgi/mnot164.py
index c29ccc185b..b365f1f5c9 100644
--- a/test/modules/http2/htdocs/cgi/mnot164.py
+++ b/test/modules/http2/htdocs/cgi/mnot164.py
@@ -1,20 +1,28 @@
#!/usr/bin/env python3
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