mirror of https://git.48k.eu/ogclient
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 OKmore_events
parent
fdf7701a03
commit
2d72f00d95
|
@ -85,8 +85,9 @@ class ogClient:
|
|||
httpparser.parser(self.data)
|
||||
print httpparser.getRequestOP()
|
||||
print httpparser.getURI()
|
||||
ogprocess.processOperation(httpparser.getRequestOP(), httpparser.getURI())
|
||||
|
||||
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
|
||||
|
|
|
@ -11,8 +11,12 @@ class ogProcess():
|
|||
def processOperation(self, op, URI):
|
||||
if ("poweroff" in URI):
|
||||
self.process_poweroff()
|
||||
return 1
|
||||
elif ("reboot" in URI):
|
||||
self.process_reboot()
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
def process_reboot(self):
|
||||
# Rebooting thread
|
||||
|
|
Loading…
Reference in New Issue