handle 'json' parameter in Extractor.request() manually

Mainly to allow passing custom classes like util.LazyPrompt,
but also to simplify and streamline how requests handles it.
This commit is contained in:
Mike Fährmann
2023-12-06 21:33:40 +01:00
parent 9dd5cb8c8a
commit 6a4218aa23

View File

@@ -136,6 +136,18 @@ class Extractor():
kwargs["timeout"] = self._timeout
if "verify" not in kwargs:
kwargs["verify"] = self._verify
if "json" in kwargs:
json = kwargs["json"]
if json is not None:
kwargs["data"] = util.json_dumps(json).encode()
del kwargs["json"]
headers = kwargs.get("headers")
if headers:
headers["Content-Type"] = "application/json"
else:
kwargs["headers"] = {"Content-Type": "application/json"}
response = None
tries = 1