From 51e7454a3c0802f1e751cab5f6ae3167846a35ad Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 29 Jun 2019 18:27:32 +0100 Subject: [PATCH] Simple busy state for POST --- daemon.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/daemon.py b/daemon.py index 6de613484..c95c9ca53 100644 --- a/daemon.py +++ b/daemon.py @@ -148,12 +148,21 @@ class PubServer(BaseHTTPRequestHandler): self._set_headers('application/json') def do_POST(self): + try: + if self.POSTbusy: + self.send_response(400) + self.end_headers() + return + except: + pass + self.POSTbusy=True ctype, pdict = cgi.parse_header(self.headers.getheader('content-type')) # refuse to receive non-json content if ctype != 'application/json': self.send_response(400) self.end_headers() + self.POSTbusy=False return # read the message and convert it into a python dictionary @@ -161,6 +170,7 @@ class PubServer(BaseHTTPRequestHandler): if length>maxMessageLength: self.send_response(400) self.end_headers() + self.POSTbusy=False return message = json.loads(self.rfile.read(length)) @@ -174,6 +184,7 @@ class PubServer(BaseHTTPRequestHandler): # send the message back self._set_headers('application/json') self.wfile.write(json.dumps(message).encode('utf-8')) + self.POSTbusy=False def runDaemon(domain: str,port=80,fedList=[],useTor=False) -> None: global thisDomain