Simple busy state for GET

master
Bob Mottram 2019-06-29 18:25:09 +01:00
parent 56881e3404
commit ac3e9de928
1 changed files with 15 additions and 0 deletions

View File

@ -90,33 +90,47 @@ class PubServer(BaseHTTPRequestHandler):
return True return True
def do_GET(self): def do_GET(self):
try:
if self.GETbusy:
self.send_response(400)
self.end_headers()
return
except:
pass
self.GETbusy=True
if not self._permittedDir(self.path): if not self._permittedDir(self.path):
self._404() self._404()
self.GETbusy=False
return return
# get webfinger endpoint for a person # get webfinger endpoint for a person
if self._webfinger(): if self._webfinger():
self.GETbusy=False
return return
# get outbox feed for a person # get outbox feed for a person
outboxFeed=personOutboxJson(thisDomain,self.path,useHttps,maxPostsInFeed) outboxFeed=personOutboxJson(thisDomain,self.path,useHttps,maxPostsInFeed)
if outboxFeed: if outboxFeed:
self._set_headers('application/json') self._set_headers('application/json')
self.wfile.write(json.dumps(outboxFeed).encode('utf-8')) self.wfile.write(json.dumps(outboxFeed).encode('utf-8'))
self.GETbusy=False
return return
# look up a person # look up a person
getPerson = personLookup(thisDomain,self.path) getPerson = personLookup(thisDomain,self.path)
if getPerson: if getPerson:
self._set_headers('application/json') self._set_headers('application/json')
self.wfile.write(json.dumps(getPerson).encode('utf-8')) self.wfile.write(json.dumps(getPerson).encode('utf-8'))
self.GETbusy=False
return return
getPersonKey = personKeyLookup(thisDomain,self.path) getPersonKey = personKeyLookup(thisDomain,self.path)
if getPersonKey: if getPersonKey:
self._set_headers('text/html; charset=utf-8') self._set_headers('text/html; charset=utf-8')
self.wfile.write(getPersonKey.encode('utf-8')) self.wfile.write(getPersonKey.encode('utf-8'))
self.GETbusy=False
return return
# check that a json file was requested # check that a json file was requested
baseDir=os.getcwd() baseDir=os.getcwd()
if not self.path.endswith('.json'): if not self.path.endswith('.json'):
self._404() self._404()
self.GETbusy=False
return return
# check that the file exists # check that the file exists
filename=baseDir+self.path filename=baseDir+self.path
@ -128,6 +142,7 @@ class PubServer(BaseHTTPRequestHandler):
self.wfile.write(json.dumps(contentJson).encode('utf8')) self.wfile.write(json.dumps(contentJson).encode('utf8'))
else: else:
self._404() self._404()
self.GETbusy=False
def do_HEAD(self): def do_HEAD(self):
self._set_headers('application/json') self._set_headers('application/json')