MCPcopy Index your code
hub / github.com/RustPython/RustPython / TestHTTPServer

Class TestHTTPServer

Lib/test/test_logging.py:985–1024  ·  view source on GitHub ↗

An HTTP server which is controllable using :class:`ControlMixin`. :param addr: A tuple with the IP address and port to listen on. :param handler: A handler callable which will be called with a single parameter - the request - in order to process

Source from the content-addressed store, hash-verified

983 self.ready.clear()
984
985class TestHTTPServer(ControlMixin, HTTPServer):
986 """
987 An HTTP server which is controllable using :class:`ControlMixin`.
988
989 :param addr: A tuple with the IP address and port to listen on.
990 :param handler: A handler callable which will be called with a
991 single parameter - the request - in order to
992 process the request.
993 :param poll_interval: The polling interval in seconds.
994 :param log: Pass ``True`` to enable log messages.
995 """
996 def __init__(self, addr, handler, poll_interval=0.5,
997 log=False, sslctx=None):
998 class DelegatingHTTPRequestHandler(BaseHTTPRequestHandler):
999 def __getattr__(self, name, default=None):
1000 if name.startswith('do_'):
1001 return self.process_request
1002 raise AttributeError(name)
1003
1004 def process_request(self):
1005 self.server._handler(self)
1006
1007 def log_message(self, format, *args):
1008 if log:
1009 super(DelegatingHTTPRequestHandler,
1010 self).log_message(format, *args)
1011 HTTPServer.__init__(self, addr, DelegatingHTTPRequestHandler)
1012 ControlMixin.__init__(self, handler, poll_interval)
1013 self.sslctx = sslctx
1014
1015 def get_request(self):
1016 try:
1017 sock, addr = self.socket.accept()
1018 if self.sslctx:
1019 sock = self.sslctx.wrap_socket(sock, server_side=True)
1020 except OSError as e:
1021 # socket errors are silenced by the caller, print them here
1022 sys.stderr.write("Got an error:\n%s\n" % e)
1023 raise
1024 return sock, addr
1025
1026class TestTCPServer(ControlMixin, ThreadingTCPServer):
1027 """

Callers 1

test_outputMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_outputMethod · 0.68