diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2020-08-28 18:10:06 +0100 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2020-08-28 18:42:44 +0100 |
commit | 4d8bf7d021eef9a491c53029a8b4c98f5a2d4750 (patch) | |
tree | 969721dbed3bc108c747e7d719569a3687b96006 /tests/server.py | |
parent | Return 400 when accessing submit_token/_confirm with REMOTE behaviour (diff) | |
download | synapse-4d8bf7d021eef9a491c53029a8b4c98f5a2d4750.tar.xz |
Convert confirmation from request args to HTML form data
Diffstat (limited to 'tests/server.py')
-rw-r--r-- | tests/server.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/server.py b/tests/server.py index b6e0b14e78..b1e5fd84fe 100644 --- a/tests/server.py +++ b/tests/server.py @@ -1,6 +1,7 @@ import json import logging from io import BytesIO +from json.decoder import JSONDecodeError import attr from zope.interface import implementer @@ -195,7 +196,19 @@ def make_request( ) if content: - req.requestHeaders.addRawHeader(b"Content-Type", b"application/json") + content_is_json = True + try: + json.loads(content) + except JSONDecodeError: + content_is_json = False + + print("Content is json?", content_is_json, path) + if content_is_json: + req.requestHeaders.addRawHeader(b"Content-Type", b"application/json") + else: + req.requestHeaders.addRawHeader( + b"Content-Type", b"application/x-www-form-urlencoded" + ) req.requestReceived(method, path, b"1.1") |