def _check_request(self):
method = cherrypy.request.method.upper()
headers = cherrypy.request.headers
# Fail for other methods than get or head
if method not in ("GET", "HEAD"):
raise cherrypy.HTTPError(405)
# Error if the requester is not allowed
# for now this is a simple check just checking if the useragent matches Kodi
user_agent = headers['User-Agent'].lower()
if not ("kodi" in user_agent or "osmc" in user_agent):
raise cherrypy.HTTPError(403)
return method
评论列表
文章目录