Package tlslite :: Package integration :: Module xmlrpcserver |
[hide private]
[frames] | no frames]

# Source Code for Module tlslite.integration.xmlrpcserver

     1  # Authors:
     2  #   Kees Bos
     3  #   Martin von Loewis - python 3 port
     4  #
     5  # See the LICENSE file for legal information regarding use of this file.
     6
     7  """xmlrpcserver.py - simple XML RPC server supporting TLS"""
     8  try:
     9      from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
    10  except ImportError:
    11      # Python 3
    12      from xmlrpc.server import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
    13  from .tlssocketservermixin import TLSSocketServerMixIn
    14
    15
    16 -class TLSXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
    17      """XMLRPCRequestHandler using TLS"""
    18
    19      # Redefine the setup method (see SocketServer.StreamRequestHandler)
    20 -    def setup(self):
    21          self.connection = self.request
    22          if getattr(self, 'timeout', None) is not None:
    23              # Python 2.7
    24              self.connection.settimeout(self.timeout)
    25          self.rfile = self.connection.makefile('rb', self.rbufsize)
    26          self.wfile = self.connection.makefile('wb', self.wbufsize)
    27
    28 -    def do_POST(self):
    29          """Handles the HTTPS POST request."""
    30          SimpleXMLRPCRequestHandler.do_POST(self)
    31          try:
    32              # shut down the connection
    33              self.connection.shutdown()
    34          except:
    35              pass
    36
    37
    38 -class TLSXMLRPCServer(TLSSocketServerMixIn,
    39                        SimpleXMLRPCServer):
    40      """Simple XML-RPC server using TLS"""
    41
    42 -    def __init__(self, addr, *args, **kwargs):
    43          if not args and not 'requestHandler' in kwargs:
    44              kwargs['requestHandler'] = TLSXMLRPCRequestHandler
    45          SimpleXMLRPCServer.__init__(self, addr, *args, **kwargs)
    46
    47
    48 -class MultiPathTLSXMLRPCServer(TLSXMLRPCServer):
    49      """Multipath XML-RPC Server using TLS"""
    50
    51 -    def __init__(self, addr, *args, **kwargs):
    52          TLSXMLRPCServer.__init__(addr, *args, **kwargs)
    53          self.dispatchers = {}
    54          self.allow_none = allow_none
    55          self.encoding = encoding
    56