mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-94172: urllib.request avoids deprecated check_hostname (#94193)
The urllib.request no longer uses the deprecated check_hostname parameter of the http.client module. Add private http.client._create_https_context() helper to http.client, used by urllib.request. Remove the now redundant check on check_hostname and verify_mode in http.client: the SSLContext.check_hostname setter already implements the check.
This commit is contained in:
parent
e69306f08b
commit
f0b234e6ed
2 changed files with 23 additions and 17 deletions
|
@ -1383,12 +1383,16 @@ if hasattr(http.client, 'HTTPSConnection'):
|
|||
|
||||
def __init__(self, debuglevel=0, context=None, check_hostname=None):
|
||||
AbstractHTTPHandler.__init__(self, debuglevel)
|
||||
if context is None:
|
||||
http_version = http.client.HTTPSConnection._http_vsn
|
||||
context = http.client._create_https_context(http_version)
|
||||
if check_hostname is not None:
|
||||
context.check_hostname = check_hostname
|
||||
self._context = context
|
||||
self._check_hostname = check_hostname
|
||||
|
||||
def https_open(self, req):
|
||||
return self.do_open(http.client.HTTPSConnection, req,
|
||||
context=self._context, check_hostname=self._check_hostname)
|
||||
context=self._context)
|
||||
|
||||
https_request = AbstractHTTPHandler.do_request_
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue