Server cleanup
This commit is contained in:
parent
6a68046fee
commit
3a4814d3a8
@ -19,6 +19,7 @@ import socket
|
|||||||
|
|
||||||
from . import util
|
from . import util
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# WebRequest
|
# WebRequest
|
||||||
#
|
#
|
||||||
@ -66,8 +67,6 @@ class WebClient:
|
|||||||
self.writeBuff += self.handler(req)
|
self.writeBuff += self.handler(req)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if wlist and self.writeBuff:
|
if wlist and self.writeBuff:
|
||||||
try:
|
try:
|
||||||
length = self.sock.send(self.writeBuff)
|
length = self.sock.send(self.writeBuff)
|
||||||
@ -154,7 +153,6 @@ class WebServer:
|
|||||||
|
|
||||||
|
|
||||||
def handlerWrapper(self, req):
|
def handlerWrapper(self, req):
|
||||||
|
|
||||||
# handle multiple cors origins by checking the 'origin'-header against the allowed origin list from the config
|
# handle multiple cors origins by checking the 'origin'-header against the allowed origin list from the config
|
||||||
webCorsOriginList = util.setting('webCorsOriginList')
|
webCorsOriginList = util.setting('webCorsOriginList')
|
||||||
|
|
||||||
@ -184,10 +182,9 @@ class WebServer:
|
|||||||
else:
|
else:
|
||||||
allowed = True
|
allowed = True
|
||||||
|
|
||||||
resp = bytes()
|
|
||||||
paramsError = False
|
|
||||||
try:
|
try:
|
||||||
params = json.loads(req.body.decode('utf-8'))
|
params = json.loads(req.body.decode('utf-8'))
|
||||||
|
paramsError = False
|
||||||
except ValueError:
|
except ValueError:
|
||||||
body = json.dumps(None).encode('utf-8')
|
body = json.dumps(None).encode('utf-8')
|
||||||
paramsError = True
|
paramsError = True
|
||||||
@ -220,6 +217,8 @@ class WebServer:
|
|||||||
]
|
]
|
||||||
body = ''.encode('utf-8');
|
body = ''.encode('utf-8');
|
||||||
|
|
||||||
|
resp = bytes()
|
||||||
|
|
||||||
for key, value in headers:
|
for key, value in headers:
|
||||||
if value is None:
|
if value is None:
|
||||||
resp += '{}\r\n'.format(key).encode('utf-8')
|
resp += '{}\r\n'.format(key).encode('utf-8')
|
||||||
|
Loading…
Reference in New Issue
Block a user