Issue #22366: urllib.request.urlopen will accept a context object (SSLContext)

as an argument which will then used be for HTTPS connection.

Patch by Alex Gaynor.
This commit is contained in:
Senthil Kumaran 2014-09-19 15:23:30 +08:00
parent ea07eb9469
commit a5c85b3f5f
4 changed files with 29 additions and 2 deletions

View file

@ -16,7 +16,7 @@ authentication, redirections, cookies and more.
The :mod:`urllib.request` module defines the following functions:
.. function:: urlopen(url, data=None[, timeout], *, cafile=None, capath=None, cadefault=False)
.. function:: urlopen(url, data=None[, timeout], *, cafile=None, capath=None, cadefault=False, context=None)
Open the URL *url*, which can be either a string or a
:class:`Request` object.
@ -47,6 +47,10 @@ The :mod:`urllib.request` module defines the following functions:
the global default timeout setting will be used). This actually
only works for HTTP, HTTPS and FTP connections.
If *context* is specified, it must be a :class:`ssl.SSLContext` instance
describing the various SSL options. See
:class:`~http.client.HTTPSConnection` for more details.
The optional *cafile* and *capath* parameters specify a set of trusted
CA certificates for HTTPS requests. *cafile* should point to a single
file containing a bundle of CA certificates, whereas *capath* should
@ -111,6 +115,9 @@ The :mod:`urllib.request` module defines the following functions:
.. versionchanged:: 3.3
*cadefault* was added.
.. versionchanged:: 3.5
*context* was added.
.. function:: install_opener(opener)
Install an :class:`OpenerDirector` instance as the default global opener.