* sending body data as prepared json to

- removing pointless asserts
- removed unused param in Request.make
This commit is contained in:
shockrah 2021-01-20 22:47:12 -08:00
parent aaa1378af8
commit 84ac9883d1

View File

@ -66,7 +66,6 @@ class Response:
class Request:
def __init__(self, method: str, url: str, params: dict):
assert(domain[len(domain) - 1] != '/')
assert(method in ['get', 'post', 'delete'])
self.method = method
@ -77,21 +76,22 @@ class Request:
# Lower driver for actuall making the request we are looking for
method = method.lower()
params = json.dumps(self.params)
if method == 'get':
resp = requests.get(self.url, data=self.params)
return Response(self.url, resp.body, resp.status_code, hope)
resp = requests.get(self.url, data=params)
return Response(self.url, resp.text, resp.status_code, hope)
elif method == 'post':
resp = requests.post(self.url, data=self.params)
return Response(self.url, resp.body, resp.status_code, hope)
resp = requests.post(self.url, data=self)
return Response(self.url, resp.text, resp.status_code, hope)
elif method == 'delete':
resp = requests.delete(self.url, data=self.params)
return Response(self.url, resp.body, resp.status_code, hope)
resp = requests.delete(self.url, data=params)
return Response(self.url, resp.text, resp.status_code, hope)
else:
raise RequestError('Invalid method passed')
def make(self, hope: int, auth: str) -> Response:
def make(self, hope: int) -> Response:
'''
@param hope: int -> status code we hope to get back
@return Response -> Wrapper around server http response