Use POST for writes (with api_sig), GET for reads
This commit is contained in:
parent
aad860a222
commit
f3467bca36
|
@ -904,6 +904,13 @@ class _Request:
|
|||
data.append("=".join((name, quote_plus(_string(self.params[name])))))
|
||||
data = "&".join(data)
|
||||
|
||||
if "api_sig" in self.params.keys():
|
||||
method = "POST"
|
||||
url_parameters = ""
|
||||
else:
|
||||
method = "GET"
|
||||
url_parameters = "?" + data
|
||||
|
||||
headers = {
|
||||
"Content-type": "application/x-www-form-urlencoded",
|
||||
"Accept-Charset": "utf-8",
|
||||
|
@ -921,8 +928,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 +940,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
|
||||
|
||||
|
|
Loading…
Reference in a new issue