summaryrefslogtreecommitdiffstats
path: root/cli/cli.py
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-07-08 11:43:49 +0200
committerRoberto Hueso Gómez <rhueso@soleta.eu>2020-07-08 11:43:49 +0200
commite3d30d23ff22bebb8e5ebf0e731aab4a14502cea (patch)
tree3ae16e07c8052f55ec54b61ad96edebd9e14ee5d /cli/cli.py
parent8961937329940e41219f0a32c4aec0aad9d81636 (diff)
Add payload option on GET requests
Instead of using query strings we use a json body for GET HTTP requests. This is allowed under RFCs 7230-7237. https://stackoverflow.com/questions/978061/http-get-with-request-body
Diffstat (limited to 'cli/cli.py')
-rw-r--r--cli/cli.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/cli/cli.py b/cli/cli.py
index 49b3930..abdfca8 100644
--- a/cli/cli.py
+++ b/cli/cli.py
@@ -18,10 +18,11 @@ class OgREST():
self.URL = f'http://{ip}:{port}'
self.HEADERS = {'Authorization' : api_token}
- def get(self, path):
+ def get(self, path, payload=None):
try:
r = requests.get(f'{self.URL}{path}',
- headers=self.HEADERS)
+ headers=self.HEADERS,
+ json=payload)
if r.status_code != 200:
sys.exit(f"Cannot connect to ogServer: "
f"{r.status_code} HTTP status code")