make url composition absorb multiple / because new version of server are sensible to it
This commit is contained in:
parent
f0e6ddf63e
commit
566ebd41db
|
@ -29,7 +29,7 @@ class BaseClient(object):
|
|||
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
|
||||
|
||||
def __init__(self, baseURL, baseResource, headers=None):
|
||||
self.baseURL = baseURL
|
||||
self.baseURL = baseURL.rstrip("/")
|
||||
self.headers = self.mergeTwoDicts(self.headers, headers) if headers != None else self.headers
|
||||
self.baseResource = baseResource
|
||||
|
||||
|
@ -43,7 +43,7 @@ class BaseClient(object):
|
|||
return resp.json()
|
||||
|
||||
def post(self, resPath, queryParams, body, headers=None, timeout=(5, 10)):
|
||||
theUrl = "{}/{}".format(self.baseURL, resPath)
|
||||
theUrl = "{}/{}".format(self.baseURL, resPath.lstrip("/"))
|
||||
theHeader = self.headers
|
||||
if headers is not None:
|
||||
theHeader = self.mergeTwoDicts(self.headers, headers)
|
||||
|
@ -57,7 +57,7 @@ class BaseClient(object):
|
|||
return self.__return(resp, theHeader)
|
||||
|
||||
def put(self, resPath, queryParams=None, body=None, headers=None, timeout=(5, 10)):
|
||||
theUrl = "{}/{}".format(self.baseURL, resPath)
|
||||
theUrl = "{}/{}".format(self.baseURL, resPath.lstrip("/"))
|
||||
theHeader = self.headers
|
||||
if headers is not None:
|
||||
theHeader = self.mergeTwoDicts(self.headers, headers)
|
||||
|
@ -72,7 +72,7 @@ class BaseClient(object):
|
|||
self.__checkForSuccess(resp)
|
||||
|
||||
def delete(self, resPath, queryParams, timeout=(5, 10)):
|
||||
theUrl = "{}/{}".format(self.baseURL, resPath)
|
||||
theUrl = "{}/{}".format(self.baseURL, resPath.lstrip("/"))
|
||||
resp = requests.delete(theUrl, params=queryParams, headers=self.headers, timeout=timeout)
|
||||
self.__print(resp)
|
||||
self.__checkForSuccess(resp)
|
||||
|
|
Loading…
Reference in New Issue