当前位置: 首页>>代码示例>>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;未经允许,请勿转载。