本文整理汇总了Python中SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.parse_request方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLRPCRequestHandler.parse_request方法的具体用法?Python SimpleXMLRPCRequestHandler.parse_request怎么用?Python SimpleXMLRPCRequestHandler.parse_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleXMLRPCServer.SimpleXMLRPCRequestHandler
的用法示例。
在下文中一共展示了SimpleXMLRPCRequestHandler.parse_request方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_request
# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCRequestHandler import parse_request [as 别名]
def parse_request(myself):
if SimpleXMLRPCRequestHandler.parse_request(myself):
header = myself.headers.get('Authorization')
if header == None:
username = None
password = None
else:
(basic, encoded) = \
header.split(' ', 2)
assert basic == 'Basic', 'Only basic authentication supported'
(username,
password) = base64.b64decode(encoded).split(':', 2)
if self.authenticate(username, password):
return True
else:
myself.send_response(401, 'Authentication failed')
myself.send_header('WWW-Authenticate',
'Basic realm="XML-RPC"')
myself.end_headers()
myself.wfile.write('Authentication failed.')
return False
示例2: parse_request
# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCRequestHandler import parse_request [as 别名]
def parse_request(self, *args):
if SimpleXMLRPCRequestHandler.parse_request(self, *args):
if self.authenticate():
return True
else:
self.send_error(401, 'Authentication failed')
return False
示例3: parse_request
# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCRequestHandler import parse_request [as 别名]
def parse_request(self):
if SimpleXMLRPCRequestHandler.parse_request(self):
if self.authenticate(self.headers):
return True
else:
self.send_error(401, "Authentication Failed")
return False
示例4: parse_request
# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCRequestHandler import parse_request [as 别名]
def parse_request(request):
if SimpleXMLRPCRequestHandler.parse_request(request):
if self.authenticate(request.headers):
return True
else:
request.send_error(401, "Authentication failed, Try again.")
return False
示例5: parse_request
# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCRequestHandler import parse_request [as 别名]
def parse_request(self):
if SimpleXMLRPCRequestHandler.parse_request(self):
# next we authenticate
if self.authenticate(self.headers):
return True
else:
# if authentication fails, tell the client
self.send_error(401, 'Authentication failed')
return False
示例6: parse_request
# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCRequestHandler import parse_request [as 别名]
def parse_request(myself):
# first, call the original implementation which returns
# True if all OK so far
if SimpleXMLRPCRequestHandler.parse_request(myself):
# next we authenticate
if self.authenticate(myself.headers):
return True
else:
# if authentication fails, tell the client
myself.send_error(401, 'Authentication failed')
return False
示例7: parse_request
# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCRequestHandler import parse_request [as 别名]
def parse_request(self):
# parser request, get authentication header and send to authenticate().
if SimpleXMLRPCRequestHandler.parse_request(self):
if self.authenticate(self.headers):
logging.info("Hass RequestHandler - Authentication success, request from %s", self.clientip)
return True
else:
self.send_error(401, 'Authentication failed')
return False
else:
logging.info("Hass RequestHandler - Authentication failed, request from %s", self.clientip)
return False