Skip to content

Commit 5cce6fd

Browse files
committed
Remove content in GET requests. Fixes #44
1 parent 4d58a98 commit 5cce6fd

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

mautrix/api.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,21 @@ async def request(self, method: Method, path: Union[PathBuilder, str],
226226
Returns:
227227
The parsed response JSON.
228228
"""
229-
content = content or {}
230229
headers = headers or {}
231230
if self.token:
232231
headers["Authorization"] = f"Bearer {self.token}"
233232
query_params = query_params or {}
234233

235-
if "Content-Type" not in headers:
236-
headers["Content-Type"] = "application/json"
237-
is_json = headers.get("Content-Type", None) == "application/json"
238-
orig_content = content
239-
if is_json and isinstance(content, (dict, list)):
240-
content = json.dumps(content)
234+
if method != Method.GET:
235+
content = content or {}
236+
if "Content-Type" not in headers:
237+
headers["Content-Type"] = "application/json"
238+
orig_content = content
239+
is_json = headers.get("Content-Type", None) == "application/json"
240+
if is_json and isinstance(content, (dict, list)):
241+
content = json.dumps(content)
242+
else:
243+
orig_content = content = None
241244
full_url = self.base_url.with_path(self._full_path(path), encoded=True)
242245
req_id = next_global_req_id()
243246

0 commit comments

Comments
 (0)