Skip to content

Commit 5bd6fe6

Browse files
committed
Only json.dumps in request() if content is json-serializable
1 parent 21bb087 commit 5bd6fe6

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

mautrix_appservice/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
from .state_store import StateStore
44
from .intent_api import IntentAPI
55

6-
__version__ = "0.3.8"
6+
__version__ = "0.3.9"
77
__author__ = "Tulir Asokan <[email protected]>"

mautrix_appservice/intent_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,10 @@ def request(self, method: str, path: str, content: Optional[Union[dict, bytes, s
184184
if method not in ["GET", "PUT", "DELETE", "POST"]:
185185
raise MatrixError("Unsupported HTTP method: %s" % method)
186186

187-
if "Content-Type" not in headers:
187+
is_json_ish = isinstance(content, (dict, list, str, int, float, bool, type(None)))
188+
if "Content-Type" not in headers and is_json_ish:
188189
headers["Content-Type"] = "application/json"
189-
if headers.get("Content-Type", None) == "application/json":
190+
if headers.get("Content-Type", None) == "application/json" and is_json_ish:
190191
content = json.dumps(content)
191192

192193
if self.identity and not self.is_real_user:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setuptools.setup(
44
name="mautrix-appservice",
5-
version="0.3.8",
5+
version="0.3.9",
66
url="https://github.com/tulir/mautrix-appservice-python",
77

88
author="Tulir Asokan",

0 commit comments

Comments
 (0)