Allow other add-ons to add headers
This commit is contained in:
parent
c4e11cfda1
commit
658763dd5b
@ -199,6 +199,19 @@ class AjaxServer:
|
|||||||
self.handler = handler
|
self.handler = handler
|
||||||
self.clients = []
|
self.clients = []
|
||||||
self.sock = None
|
self.sock = None
|
||||||
|
self.resetHeaders()
|
||||||
|
|
||||||
|
|
||||||
|
def addHeader(self, name, value):
|
||||||
|
self.headers.append([name, value])
|
||||||
|
|
||||||
|
|
||||||
|
def resetHeaders(self):
|
||||||
|
self.headers = [
|
||||||
|
['HTTP/1.1 200 OK', None],
|
||||||
|
['Content-Type', 'text/json'],
|
||||||
|
['Content-Length', '']
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def advance(self):
|
def advance(self):
|
||||||
@ -243,11 +256,9 @@ class AjaxServer:
|
|||||||
body = json.dumps(None);
|
body = json.dumps(None);
|
||||||
|
|
||||||
resp = bytes()
|
resp = bytes()
|
||||||
headers = [
|
|
||||||
['HTTP/1.1 200 OK', None],
|
headers = self.headers
|
||||||
['Content-Type', 'text/json'],
|
headers[2][1] = str(len(body))
|
||||||
['Content-Length', str(len(body))]
|
|
||||||
]
|
|
||||||
|
|
||||||
for key, value in headers:
|
for key, value in headers:
|
||||||
if value is None:
|
if value is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user