Server cleanup

This commit is contained in:
Alex Yatskov 2021-07-18 10:34:13 -07:00
parent 6a68046fee
commit 3a4814d3a8

View File

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