本文整理汇总了Python中test.ssl_servers.make_https_server函数的典型用法代码示例。如果您正苦于以下问题:Python make_https_server函数的具体用法?Python make_https_server怎么用?Python make_https_server使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_https_server函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: start_https_server
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:Eyepea,项目名称:cpython,代码行数:10,代码来源:test_urllib2_localnet.py
示例2: start_https_server
def start_https_server(self, responses=None, certfile=CERT_localhost):
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, certfile=certfile, handler_class=handler)
handler.port = server.port
return handler
开发者ID:hycxa,项目名称:kbengine,代码行数:11,代码来源:test_urllib2_localnet.py
示例3: test_local_good_hostname
def test_local_good_hostname(self):
# The (valid) cert validates the HTTP hostname
import ssl
from test.ssl_servers import make_https_server
server = make_https_server(self, CERT_localhost)
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations(CERT_localhost)
h = client.HTTPSConnection('localhost', server.port, context=context)
h.request('GET', '/nonexistent')
resp = h.getresponse()
self.assertEqual(resp.status, 404)
开发者ID:edmundgentle,项目名称:schoolscript,代码行数:12,代码来源:test_httplib.py
示例4: test_local_bad_hostname
def test_local_bad_hostname(self):
# The (valid) cert doesn't validate the HTTP hostname
import ssl
from test.ssl_servers import make_https_server
server = make_https_server(self, CERT_fakehostname)
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations(CERT_fakehostname)
h = client.HTTPSConnection("localhost", server.port, context=context)
with self.assertRaises(ssl.CertificateError):
h.request("GET", "/")
# Same with explicit check_hostname=True
h = client.HTTPSConnection("localhost", server.port, context=context, check_hostname=True)
with self.assertRaises(ssl.CertificateError):
h.request("GET", "/")
# With check_hostname=False, the mismatching is ignored
h = client.HTTPSConnection("localhost", server.port, context=context, check_hostname=False)
h.request("GET", "/nonexistent")
resp = h.getresponse()
self.assertEqual(resp.status, 404)
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:21,代码来源:test_httplib.py
示例5: make_server
def make_server(self, certfile):
from test.ssl_servers import make_https_server
return make_https_server(self, certfile=certfile)
开发者ID:chidea,项目名称:GoPythonDLLWrapper,代码行数:3,代码来源:test_httplib.py
注:本文中的test.ssl_servers.make_https_server函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论