From 335abfb6f6a24f24be7e83722955610d199785fa Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sat, 24 Dec 2022 12:21:20 +0000 Subject: [PATCH] Fix postData --- commands/pygg.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/commands/pygg.py b/commands/pygg.py index cf3ecfd..4496e10 100644 --- a/commands/pygg.py +++ b/commands/pygg.py @@ -14,9 +14,9 @@ CLOUDPROXY_ENDPOINT = os.getenv("CLOUDPROXY_ENDPOINT") class FlareRequests(requests.Session): - def request(self, method, url, params=None, **kwargs): + def request(self, method, url, params=None, data=None, **kwargs): if not CLOUDPROXY_ENDPOINT: - return super().request(method, url, params, **kwargs) + return super().request(method, url, params, data, **kwargs) sessions = requests.post( CLOUDPROXY_ENDPOINT, json={"cmd": "sessions.list"} @@ -35,14 +35,16 @@ class FlareRequests(requests.Session): else: raise requests.RequestException(response) + url += "&" if len(url.split("?")) > 1 else "?" + post_data = { "cmd": f"request.{method.lower()}", "session": FLARESESSION, - "url": url, + "url": f"{url}{urllib.parse.urlencode(params)}", } - if params: - post_data["postData"] = urllib.parse.urlencode(params) + if data: + post_data["postData"] = urllib.parse.urlencode(data) try: response = requests.post(