forked from indymedia/epicyon
Simple busy state for POST
parent
ac3e9de928
commit
51e7454a3c
11
daemon.py
11
daemon.py
|
@ -148,12 +148,21 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self._set_headers('application/json')
|
self._set_headers('application/json')
|
||||||
|
|
||||||
def do_POST(self):
|
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'))
|
ctype, pdict = cgi.parse_header(self.headers.getheader('content-type'))
|
||||||
|
|
||||||
# refuse to receive non-json content
|
# refuse to receive non-json content
|
||||||
if ctype != 'application/json':
|
if ctype != 'application/json':
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
self.POSTbusy=False
|
||||||
return
|
return
|
||||||
|
|
||||||
# read the message and convert it into a python dictionary
|
# read the message and convert it into a python dictionary
|
||||||
|
@ -161,6 +170,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if length>maxMessageLength:
|
if length>maxMessageLength:
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
self.POSTbusy=False
|
||||||
return
|
return
|
||||||
message = json.loads(self.rfile.read(length))
|
message = json.loads(self.rfile.read(length))
|
||||||
|
|
||||||
|
@ -174,6 +184,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# send the message back
|
# send the message back
|
||||||
self._set_headers('application/json')
|
self._set_headers('application/json')
|
||||||
self.wfile.write(json.dumps(message).encode('utf-8'))
|
self.wfile.write(json.dumps(message).encode('utf-8'))
|
||||||
|
self.POSTbusy=False
|
||||||
|
|
||||||
def runDaemon(domain: str,port=80,fedList=[],useTor=False) -> None:
|
def runDaemon(domain: str,port=80,fedList=[],useTor=False) -> None:
|
||||||
global thisDomain
|
global thisDomain
|
||||||
|
|
Loading…
Reference in New Issue