diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2011-05-20 23:34:51 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2011-05-20 23:34:51 (GMT) |
commit | 32565b6c02e9673f9f9368f233e862dfc8a702c9 (patch) | |
tree | 4e111b381a4a18f293701f0a04c34dcd71c9d444 /Lib | |
parent | bb00976fbf26f29ab72eeb6afc2d7b4fa1944965 (diff) | |
download | cpython-32565b6c02e9673f9f9368f233e862dfc8a702c9.zip cpython-32565b6c02e9673f9f9368f233e862dfc8a702c9.tar.gz cpython-32565b6c02e9673f9f9368f233e862dfc8a702c9.tar.bz2 |
Added SSL capability to TestHTTPServer.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_logging.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 24a6149..09d28eb 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -810,7 +810,8 @@ if threading: :param poll_interval: The polling interval in seconds. :param log: Pass ``True`` to enable log messages. """ - def __init__(self, addr, handler, poll_interval=0.5, log=False): + def __init__(self, addr, handler, poll_interval=0.5, + log=False, sslctx=None): class DelegatingHTTPRequestHandler(BaseHTTPRequestHandler): def __getattr__(self, name, default=None): if name.startswith('do_'): @@ -826,6 +827,18 @@ if threading: self).log_message(format, *args) HTTPServer.__init__(self, addr, DelegatingHTTPRequestHandler) ControlMixin.__init__(self, handler, poll_interval) + self.sslctx = sslctx + + def get_request(self): + try: + sock, addr = self.socket.accept() + if self.sslctx: + sock = self.sslctx.wrap_socket(sock, server_side=True) + except socket.error as e: + # socket errors are silenced by the caller, print them here + sys.stderr.write("Got an error:\n%s\n" % e) + raise + return sock, addr class TestTCPServer(ControlMixin, ThreadingTCPServer): """ |