mirror of https://git.48k.eu/ogclient
parent
8e81b8091e
commit
a85c113ee7
|
@ -98,7 +98,7 @@ class ogClient:
|
||||||
|
|
||||||
if self.trailer and len(self.data) >= self.content_len:
|
if self.trailer and len(self.data) >= self.content_len:
|
||||||
request.parser(self.data)
|
request.parser(self.data)
|
||||||
self.ogrest.processOperation(request, self)
|
self.ogrest.process_request(request, self)
|
||||||
|
|
||||||
# Cleanup state information from request
|
# Cleanup state information from request
|
||||||
self.data = ""
|
self.data = ""
|
||||||
|
|
|
@ -236,8 +236,8 @@ class ogRest():
|
||||||
self.terminated = False
|
self.terminated = False
|
||||||
self.state = ThreadState.IDLE
|
self.state = ThreadState.IDLE
|
||||||
|
|
||||||
def processOperation(self, request, client):
|
def process_request(self, request, client):
|
||||||
op = request.getRequestOP()
|
method = request.get_method()
|
||||||
URI = request.getURI()
|
URI = request.getURI()
|
||||||
|
|
||||||
if (not "stop" in URI and
|
if (not "stop" in URI and
|
||||||
|
@ -251,7 +251,7 @@ class ogRest():
|
||||||
else:
|
else:
|
||||||
self.state = ThreadState.BUSY
|
self.state = ThreadState.BUSY
|
||||||
|
|
||||||
if ("GET" in op):
|
if ("GET" in method):
|
||||||
if "hardware" in URI:
|
if "hardware" in URI:
|
||||||
self.process_hardware(client)
|
self.process_hardware(client)
|
||||||
elif ("run/schedule" in URI):
|
elif ("run/schedule" in URI):
|
||||||
|
@ -261,7 +261,7 @@ class ogRest():
|
||||||
else:
|
else:
|
||||||
response = restResponse(ogResponses.BAD_REQUEST)
|
response = restResponse(ogResponses.BAD_REQUEST)
|
||||||
client.send(response.get())
|
client.send(response.get())
|
||||||
elif ("POST" in op):
|
elif ("POST" in method):
|
||||||
if ("poweroff" in URI):
|
if ("poweroff" in URI):
|
||||||
self.process_poweroff(client)
|
self.process_poweroff(client)
|
||||||
elif "probe" in URI:
|
elif "probe" in URI:
|
||||||
|
|
|
@ -48,7 +48,7 @@ class restRequest:
|
||||||
self.contentLen = int(self.headers['Content-Length'])
|
self.contentLen = int(self.headers['Content-Length'])
|
||||||
|
|
||||||
if (not self.requestLine == None or not self.requestLine == ''):
|
if (not self.requestLine == None or not self.requestLine == ''):
|
||||||
self.operation = self.requestLine.split('/', 1)[0]
|
self.method = self.requestLine.split('/', 1)[0]
|
||||||
self.URI = self.requestLine.split('/', 1)[1]
|
self.URI = self.requestLine.split('/', 1)[1]
|
||||||
|
|
||||||
if not self.contentLen == 0:
|
if not self.contentLen == 0:
|
||||||
|
@ -100,8 +100,8 @@ class restRequest:
|
||||||
if "code" in json_param:
|
if "code" in json_param:
|
||||||
self.code = json_param["code"]
|
self.code = json_param["code"]
|
||||||
|
|
||||||
def getRequestOP(self):
|
def get_method(self):
|
||||||
return self.operation
|
return self.method
|
||||||
|
|
||||||
def getURI(self):
|
def getURI(self):
|
||||||
return self.URI
|
return self.URI
|
||||||
|
|
Loading…
Reference in New Issue