Compare commits

...

2 commits

Author SHA1 Message Date
Hugo 0f26b6cc8a Add more logging 2021-04-30 22:06:38 +03:00
Hugo f3467bca36 Use POST for writes (with api_sig), GET for reads 2021-04-30 22:06:38 +03:00

View file

@ -903,6 +903,15 @@ class _Request:
for name in self.params.keys():
data.append("=".join((name, quote_plus(_string(self.params[name])))))
data = "&".join(data)
logger.debug(data)
if "api_sig" in self.params.keys():
method = "POST"
url_parameters = ""
else:
method = "GET"
url_parameters = "?" + data
logger.debug(method)
headers = {
"Content-type": "application/x-www-form-urlencoded",
@ -921,8 +930,8 @@ class _Request:
try:
conn.request(
method="POST",
url="https://" + host_name + host_subdir,
method=method,
url="https://" + host_name + host_subdir + url_parameters,
body=data,
headers=headers,
)
@ -933,7 +942,12 @@ class _Request:
conn = HTTPSConnection(context=SSL_CONTEXT, host=host_name)
try:
conn.request(method="POST", url=host_subdir, body=data, headers=headers)
conn.request(
method=method,
url=host_subdir + url_parameters,
body=data,
headers=headers,
)
except Exception as e:
raise NetworkError(self.network, e) from e
@ -954,6 +968,7 @@ class _Request:
self._check_response_for_errors(response_text)
finally:
conn.close()
logger.debug(response_text)
return response_text
def execute(self, cacheable=False):