summaryrefslogtreecommitdiffstats
path: root/testing/condprofile/condprof/patch.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/condprofile/condprof/patch.py
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--testing/condprofile/condprof/patch.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/testing/condprofile/condprof/patch.py b/testing/condprofile/condprof/patch.py
new file mode 100644
index 0000000000..35e4c978b5
--- /dev/null
+++ b/testing/condprofile/condprof/patch.py
@@ -0,0 +1,47 @@
+# flake8: noqa
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# patch for https://bugzilla.mozilla.org/show_bug.cgi?id=1655869
+# see https://github.com/HDE/arsenic/issues/85
+from arsenic.connection import *
+
+
+@ensure_task
+async def request(self, *, url: str, method: str, data=None) -> Tuple[int, Any]:
+ if data is None:
+ data = {}
+ if method not in {"POST", "PUT"}:
+ data = None
+ headers = {}
+ else:
+ headers = {"Content-Type": "application/json"}
+ body = json.dumps(data) if data is not None else None
+ full_url = self.prefix + url
+ log.info(
+ "request", url=strip_auth(full_url), method=method, body=body, headers=headers
+ )
+
+ async with self.session.request(
+ url=full_url, method=method, data=body, headers=headers
+ ) as response:
+ response_body = await response.read()
+ try:
+ data = json.loads(response_body)
+ except JSONDecodeError as exc:
+ log.error("json-decode", body=response_body)
+ data = {"error": "!internal", "message": str(exc), "stacktrace": ""}
+ wrap_screen(data)
+ log.info(
+ "response",
+ url=strip_auth(full_url),
+ method=method,
+ body=body,
+ response=response,
+ data=data,
+ )
+ return response.status, data
+
+
+Connection.request = request