Patchwork [2,of,5] hgweb.server: drop support for Python 2.4

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 2, 2015, 8:26 p.m.
Message ID <b04040adc66314dae044.1446495991@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11261/
State Accepted
Headers show

Comments

Siddharth Agarwal - Nov. 2, 2015, 8:26 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1445729022 25200
#      Sat Oct 24 16:23:42 2015 -0700
# Branch stable
# Node ID b04040adc66314dae044866d72c5b58c53074c30
# Parent  ff468ef482c26894af3c7d9b30001d3167db04bc
hgweb.server: drop support for Python 2.4

Patch

diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -197,47 +197,6 @@  class _httprequesthandler(BaseHTTPServer
             self.wfile.write('0\r\n\r\n')
             self.wfile.flush()
 
-class _httprequesthandleropenssl(_httprequesthandler):
-    """HTTPS handler based on pyOpenSSL"""
-
-    url_scheme = 'https'
-
-    @staticmethod
-    def preparehttpserver(httpserver, ssl_cert):
-        try:
-            import OpenSSL
-            OpenSSL.SSL.Context
-        except ImportError:
-            raise error.Abort(_("SSL support is unavailable"))
-        ctx = OpenSSL.SSL.Context(OpenSSL.SSL.TLSv1_METHOD)
-        ctx.use_privatekey_file(ssl_cert)
-        ctx.use_certificate_file(ssl_cert)
-        sock = socket.socket(httpserver.address_family, httpserver.socket_type)
-        httpserver.socket = OpenSSL.SSL.Connection(ctx, sock)
-        httpserver.server_bind()
-        httpserver.server_activate()
-
-    def setup(self):
-        self.connection = self.request
-        self.rfile = socket._fileobject(self.request, "rb", self.rbufsize)
-        self.wfile = socket._fileobject(self.request, "wb", self.wbufsize)
-
-    def do_write(self):
-        import OpenSSL
-        try:
-            _httprequesthandler.do_write(self)
-        except OpenSSL.SSL.SysCallError as inst:
-            if inst.args[0] != errno.EPIPE:
-                raise
-
-    def handle_one_request(self):
-        import OpenSSL
-        try:
-            _httprequesthandler.handle_one_request(self)
-        except (OpenSSL.SSL.SysCallError, OpenSSL.SSL.ZeroReturnError):
-            self.close_connection = True
-            pass
-
 class _httprequesthandlerssl(_httprequesthandler):
     """HTTPS handler based on Python's ssl module"""
 
@@ -311,10 +270,7 @@  class IPv6HTTPServer(MercurialHTTPServer
 def create_server(ui, app):
 
     if ui.config('web', 'certificate'):
-        if sys.version_info >= (2, 6):
-            handler = _httprequesthandlerssl
-        else:
-            handler = _httprequesthandleropenssl
+        handler = _httprequesthandlerssl
     else:
         handler = _httprequesthandler