當前位置: 首頁>>代碼示例>>Python>>正文


Python ssl_servers.make_https_server方法代碼示例

本文整理匯總了Python中test.ssl_servers.make_https_server方法的典型用法代碼示例。如果您正苦於以下問題:Python ssl_servers.make_https_server方法的具體用法?Python ssl_servers.make_https_server怎麽用?Python ssl_servers.make_https_server使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在test.ssl_servers的用法示例。


在下文中一共展示了ssl_servers.make_https_server方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_socketserver

# 需要導入模塊: from test import ssl_servers [as 別名]
# 或者: from test.ssl_servers import make_https_server [as 別名]
def test_socketserver(self):
            """Using a SocketServer to create and manage SSL connections."""
            server = make_https_server(self, certfile=CERTFILE)
            # try to connect
            if support.verbose:
                sys.stdout.write('\n')
            with open(CERTFILE, 'rb') as f:
                d1 = f.read()
            d2 = ''
            # now fetch the same data from the HTTPS server
            url = 'https://localhost:%d/%s' % (
                server.port, os.path.split(CERTFILE)[1])
            context = ssl.create_default_context(cafile=CERTFILE)
            f = urllib2.urlopen(url, context=context)
            try:
                dlen = f.info().getheader("content-length")
                if dlen and (int(dlen) > 0):
                    d2 = f.read(int(dlen))
                    if support.verbose:
                        sys.stdout.write(
                            " client: read %d bytes from remote server '%s'\n"
                            % (len(d2), server))
            finally:
                f.close()
            self.assertEqual(d1, d2) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:27,代碼來源:test_ssl.py

示例2: test_socketserver

# 需要導入模塊: from test import ssl_servers [as 別名]
# 或者: from test.ssl_servers import make_https_server [as 別名]
def test_socketserver(self):
            """Using a SocketServer to create and manage SSL connections."""
            server = make_https_server(self, certfile=CERTFILE)
            # try to connect
            if support.verbose:
                sys.stdout.write('\n')
            with open(CERTFILE, 'rb') as f:
                d1 = f.read()
            d2 = ''
            # now fetch the same data from the HTTPS server
            url = 'https://localhost:%d/%s' % (
                server.port, os.path.split(CERTFILE)[1])
            context = ssl.create_default_context(cafile=CERTFILE)
            f = urllib.request.urlopen(url, context=context)
            try:
                dlen = f.info().get("content-length")
                if dlen and (int(dlen) > 0):
                    d2 = f.read(int(dlen))
                    if support.verbose:
                        sys.stdout.write(
                            " client: read %d bytes from remote server '%s'\n"
                            % (len(d2), server))
            finally:
                f.close()
            self.assertEqual(d1, d2) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:27,代碼來源:test_ssl.py

示例3: test_socketserver

# 需要導入模塊: from test import ssl_servers [as 別名]
# 或者: from test.ssl_servers import make_https_server [as 別名]
def test_socketserver(self):
            """Using socketserver to create and manage SSL connections."""
            server = make_https_server(self, certfile=CERTFILE)
            # try to connect
            if support.verbose:
                sys.stdout.write('\n')
            with open(CERTFILE, 'rb') as f:
                d1 = f.read()
            d2 = ''
            # now fetch the same data from the HTTPS server
            url = 'https://localhost:%d/%s' % (
                server.port, os.path.split(CERTFILE)[1])
            context = ssl.create_default_context(cafile=CERTFILE)
            f = urllib.request.urlopen(url, context=context)
            try:
                dlen = f.info().get("content-length")
                if dlen and (int(dlen) > 0):
                    d2 = f.read(int(dlen))
                    if support.verbose:
                        sys.stdout.write(
                            " client: read %d bytes from remote server '%s'\n"
                            % (len(d2), server))
            finally:
                f.close()
            self.assertEqual(d1, d2) 
開發者ID:ShikyoKira,項目名稱:Project-New-Reign---Nemesis-Main,代碼行數:27,代碼來源:test_ssl.py

示例4: test_socketserver

# 需要導入模塊: from test import ssl_servers [as 別名]
# 或者: from test.ssl_servers import make_https_server [as 別名]
def test_socketserver(self):
        """Using socketserver to create and manage SSL connections."""
        server = make_https_server(self, certfile=SIGNED_CERTFILE)
        # try to connect
        if support.verbose:
            sys.stdout.write('\n')
        with open(CERTFILE, 'rb') as f:
            d1 = f.read()
        d2 = ''
        # now fetch the same data from the HTTPS server
        url = 'https://localhost:%d/%s' % (
            server.port, os.path.split(CERTFILE)[1])
        context = ssl.create_default_context(cafile=SIGNING_CA)
        f = urllib.request.urlopen(url, context=context)
        try:
            dlen = f.info().get("content-length")
            if dlen and (int(dlen) > 0):
                d2 = f.read(int(dlen))
                if support.verbose:
                    sys.stdout.write(
                        " client: read %d bytes from remote server '%s'\n"
                        % (len(d2), server))
        finally:
            f.close()
        self.assertEqual(d1, d2) 
開發者ID:bkerler,項目名稱:android_universal,代碼行數:27,代碼來源:test_ssl.py

示例5: start_https_server

# 需要導入模塊: from test import ssl_servers [as 別名]
# 或者: from test.ssl_servers import make_https_server [as 別名]
def start_https_server(self, responses=None, **kwargs):
        if not hasattr(urllib2, 'HTTPSHandler'):
            self.skipTest('ssl support required')
        from test.ssl_servers import make_https_server
        if responses is None:
            responses = [(200, [], b"we care a bit")]
        handler = GetRequestHandler(responses)
        server = make_https_server(self, handler_class=handler, **kwargs)
        handler.port = server.port
        return handler 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:test_urllib2_localnet.py

示例6: make_server

# 需要導入模塊: from test import ssl_servers [as 別名]
# 或者: from test.ssl_servers import make_https_server [as 別名]
def make_server(self, certfile):
        from test.ssl_servers import make_https_server
        return make_https_server(self, certfile=certfile) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:5,代碼來源:test_httplib.py

示例7: start_https_server

# 需要導入模塊: from test import ssl_servers [as 別名]
# 或者: from test.ssl_servers import make_https_server [as 別名]
def start_https_server(self, responses=None, **kwargs):
        if not hasattr(urllib.request, 'HTTPSHandler'):
            self.skipTest('ssl support required')
        from test.ssl_servers import make_https_server
        if responses is None:
            responses = [(200, [], b"we care a bit")]
        handler = GetRequestHandler(responses)
        server = make_https_server(self, handler_class=handler, **kwargs)
        handler.port = server.port
        return handler 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:12,代碼來源:test_urllib2_localnet.py


注:本文中的test.ssl_servers.make_https_server方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。