本文整理汇总了Python中jsonrpclib.SimpleJSONRPCServer.SimpleJSONRPCRequestHandler类的典型用法代码示例。如果您正苦于以下问题:Python SimpleJSONRPCRequestHandler类的具体用法?Python SimpleJSONRPCRequestHandler怎么用?Python SimpleJSONRPCRequestHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleJSONRPCRequestHandler类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_POST
def do_POST(self):
# pylint: disable=E1101
if self.path == '/RPC2':
SimpleJSONRPCRequestHandler.do_POST(self)
else:
__pychecker__ = 'no-classattr'
SimpleHTTPRequestHandler.do_POST(self)
示例2: do_POST
def do_POST(self):
if self.auth_map != None:
if self.headers.has_key('authorization') and self.headers['authorization'].startswith('Basic '):
authenticationString = base64.b64decode(self.headers['authorization'].split(' ')[1])
if authenticationString.find(':') != -1:
username, password = authenticationString.split(':', 1)
self.logger.info('Got request from %s:%s' % (username, password))
if self.auth_map.has_key(username) and self.verifyPassword(username, password):
return SimpleJSONRPCRequestHandler.do_POST(self)
else:
self.logger.error('Authentication failed for %s:%s' % (username, password))
self.logger.error('Authentication failed')
self.send_response(401)
self.end_headers()
return False
return SimpleJSONRPCRequestHandler.do_POST(self)
示例3: parse_request
def parse_request(myself):
# first, call the original implementation which returns
# True if all OK so far
if SimpleJSONRPCRequestHandler.parse_request(myself):
try:
self.authenticate(myself.headers)
return True
except (RPCAuthCredentialsInvalid, RPCAuthCredentialsMissing,
RPCAuthUnsupportedType) as e:
myself.send_error(401, str(e))
except BaseException as e:
import traceback, sys
traceback.print_exc(file=sys.stderr)
myself.send_error(500, str(e))
return False
示例4: parse_request
def parse_request(myself):
# first, call the original implementation which returns
# True if all OK so far
if SimpleJSONRPCRequestHandler.parse_request(myself):
# Do not authenticate OPTIONS-requests
if myself.command.strip() == 'OPTIONS':
return True
try:
self.authenticate(myself.headers)
return True
except (RPCAuthCredentialsInvalid, RPCAuthCredentialsMissing,
RPCAuthUnsupportedType) as e:
myself.send_error(401, str(e))
except BaseException as e:
self.logger.exception('')
myself.send_error(500, str(e))
return False
示例5: end_headers
def end_headers(self):
self.send_header("Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept")
self.send_header("Access-Control-Allow-Origin", "*")
SimpleJSONRPCRequestHandler.end_headers(self)
示例6: end_headers
def end_headers(self):
self.send_header("Access-Control-Allow-Origin", "*")
SimpleJSONRPCRequestHandler.end_headers(self)
示例7: __init__
def __init__(self, request, client_address, server, client_digest=None):
self.logger = logging.getLogger(__name__)
self.auth_map = server.auth_map
SimpleJSONRPCRequestHandler.__init__(self, request, client_address, server)
self.client_digest = client_digest
示例8: do_POST
def do_POST(self):
if self.client_address[0] not in allowed_ips:
self.send_error(403,"Your address is not in allowed_ips")
return
SimpleJSONRPCRequestHandler.do_POST(self)
示例9: setup
def setup(self):
"""Prepare to handle a request."""
rv = SimpleRPCRequestHandler.setup(self)
# StreamRequestHandler will have duped our PipeSocket via
# makefile(), so close the connection socket here.
self.connection.close()
return rv
示例10: finish
def finish(self):
for sig in _MASKED_SIGS:
signal.signal(sig, _SIG_HANDLERS[sig])
if _deferred_sig:
os.kill(os.getpid(), _deferred_sig)
return handler.finish(self)
示例11: handle
def handle(self):
return handler.handle(self)
示例12: setup
def setup(self):
for sig in _MASKED_SIGS:
signal.signal(sig, _defer_sig)
return handler.setup(self)