summaryrefslogtreecommitdiffstats
path: root/src/ogClient.py
diff options
context:
space:
mode:
authorAlvaro Neira Ayuso <aneira@soleta.eu>2019-12-12 18:27:39 +0100
committerAlvaro Neira Ayuso <alvaroneay@gmail.com>2020-01-19 19:50:44 +0100
commit2d72f00d95339d15764580bc0ebcfcfc04b4854d (patch)
tree068b27ddc4578c42b3d2e311922b5fe0317045ef /src/ogClient.py
parentfdf7701a039b36beebb05296dbf28a10bd5588d2 (diff)
Send bad request when the APIRest operation is not supported
Our program sends always the HTTP message: HTTP/1.0 200 OK but if the operation sent is not supported, we are sending the same correct message. This patch add the support to check if the message is supported. If the message is not supported, we are going to send: HTTP/1.0 400 Bad request\r\n\r\n Otherwise, in operations supported: HTTP/1.0 200 OK
Diffstat (limited to 'src/ogClient.py')
-rw-r--r--src/ogClient.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/ogClient.py b/src/ogClient.py
index 05c243d..3f7a752 100644
--- a/src/ogClient.py
+++ b/src/ogClient.py
@@ -85,9 +85,10 @@ class ogClient:
httpparser.parser(self.data)
print httpparser.getRequestOP()
print httpparser.getURI()
- ogprocess.processOperation(httpparser.getRequestOP(), httpparser.getURI())
-
- self.sock.send("HTTP/1.0 200 OK\r\n\r\n")
+ if not ogprocess.processOperation(httpparser.getRequestOP(), httpparser.getURI()):
+ self.sock.send("HTTP/1.0 400 Bad request\r\n\r\n")
+ else:
+ self.sock.send("HTTP/1.0 200 OK\r\n\r\n")
# Cleanup state information from request
self.data = ""