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.append("=".join((name, quote_plus(_string(self.params[name])))))
|
||||||
data = "&".join(data)
|
data = "&".join(data)
|
||||||
|
|
||||||
|
if "api_sig" in self.params.keys():
|
||||||
|
method = "POST"
|
||||||
|
url_parameters = ""
|
||||||
|
else:
|
||||||
|
method = "GET"
|
||||||
|
url_parameters = "?" + data
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"Content-type": "application/x-www-form-urlencoded",
|
"Content-type": "application/x-www-form-urlencoded",
|
||||||
"Accept-Charset": "utf-8",
|
"Accept-Charset": "utf-8",
|
||||||
|
@ -921,8 +928,8 @@ class _Request:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn.request(
|
conn.request(
|
||||||
method="POST",
|
method=method,
|
||||||
url="https://" + host_name + host_subdir,
|
url="https://" + host_name + host_subdir + url_parameters,
|
||||||
body=data,
|
body=data,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
)
|
)
|
||||||
|
@ -933,7 +940,12 @@ class _Request:
|
||||||
conn = HTTPSConnection(context=SSL_CONTEXT, host=host_name)
|
conn = HTTPSConnection(context=SSL_CONTEXT, host=host_name)
|
||||||
|
|
||||||
try:
|
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:
|
except Exception as e:
|
||||||
raise NetworkError(self.network, e) from e
|
raise NetworkError(self.network, e) from e
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue