Alternatively send request data using "params" if request method is GET

Previously we sent it always as "data", which caused problems for GET
requests where there is no request body.

(imported from commit 20084d1da1b8228cc484536ca4d6f77f547a9d78)
This commit is contained in:
Luke Faraone 2013-03-28 12:47:26 -07:00
parent e4f3bf881c
commit 1b9a98e559

View file

@ -137,13 +137,18 @@ class Client(object):
while True: while True:
try: try:
if method == "GET":
kwarg = "params"
else:
kwarg = "data"
kwargs = {kwarg: query_state["request"]}
res = requests.request( res = requests.request(
method, method,
urlparse.urljoin(self.base_url, url), urlparse.urljoin(self.base_url, url),
auth=requests.auth.HTTPBasicAuth(self.email, auth=requests.auth.HTTPBasicAuth(self.email,
self.api_key), self.api_key),
data=query_state["request"], verify=True, timeout=55,
verify=True, timeout=55) **kwargs)
# On 50x errors, try again after a short sleep # On 50x errors, try again after a short sleep
if str(res.status_code).startswith('5'): if str(res.status_code).startswith('5'):