Return 404 is path doesn't match

main
Bob Mottram 2019-11-15 13:45:21 +00:00
parent 6b4a23bcd3
commit f84c800cb1
1 changed files with 9 additions and 2 deletions

View File

@ -394,13 +394,14 @@ class PubServer(BaseHTTPRequestHandler):
self._write(msg) self._write(msg)
print('instance activity metadata sent') print('instance activity metadata sent')
return True return True
return False self._404()
return True
def _nodeinfo(self) -> bool: def _nodeinfo(self) -> bool:
if not self.path.startswith('/nodeinfo/2.0'): if not self.path.startswith('/nodeinfo/2.0'):
return False return False
if self.server.debug: if self.server.debug:
print('DEBUG: nodeinfo '+self.path) print('DEBUG: nodeinfo '+self.path)
info=metaDataNodeInfo(self.server.baseDir,self.server.registration,self.server.projectVersion) info=metaDataNodeInfo(self.server.baseDir,self.server.registration,self.server.projectVersion)
if info: if info:
msg=json.dumps(info).encode('utf-8') msg=json.dumps(info).encode('utf-8')
@ -413,6 +414,8 @@ class PubServer(BaseHTTPRequestHandler):
self._set_headers('application/ld+json',len(msg),None) self._set_headers('application/ld+json',len(msg),None)
self._write(msg) self._write(msg)
print('nodeinfo sent') print('nodeinfo sent')
return True
self._404()
return True return True
def _webfinger(self) -> bool: def _webfinger(self) -> bool:
@ -429,6 +432,8 @@ class PubServer(BaseHTTPRequestHandler):
msg=wfResult.encode('utf-8') msg=wfResult.encode('utf-8')
self._set_headers('application/xrd+xml',len(msg),None) self._set_headers('application/xrd+xml',len(msg),None)
self._write(msg) self._write(msg)
return True
self._404()
return True return True
if self.path.startswith('/.well-known/nodeinfo'): if self.path.startswith('/.well-known/nodeinfo'):
wfResult=webfingerNodeInfo(self.server.httpPrefix,self.server.domainFull) wfResult=webfingerNodeInfo(self.server.httpPrefix,self.server.domainFull)
@ -442,6 +447,8 @@ class PubServer(BaseHTTPRequestHandler):
else: else:
self._set_headers('application/ld+json',len(msg),None) self._set_headers('application/ld+json',len(msg),None)
self._write(msg) self._write(msg)
return True
self._404()
return True return True
if self.server.debug: if self.server.debug: