Update request urllib3 (#464)
* requests: updated to version 2.27.1 * urllib3: updated to version 1.26.18
This commit is contained in:
+26
-6
@@ -1,8 +1,10 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .filepost import encode_multipart_formdata
|
||||
from .packages.six.moves.urllib.parse import urlencode
|
||||
import sys
|
||||
|
||||
from .filepost import encode_multipart_formdata
|
||||
from .packages import six
|
||||
from .packages.six.moves.urllib.parse import urlencode
|
||||
|
||||
__all__ = ["RequestMethods"]
|
||||
|
||||
@@ -10,8 +12,8 @@ __all__ = ["RequestMethods"]
|
||||
class RequestMethods(object):
|
||||
"""
|
||||
Convenience mixin for classes who implement a :meth:`urlopen` method, such
|
||||
as :class:`~urllib3.connectionpool.HTTPConnectionPool` and
|
||||
:class:`~urllib3.poolmanager.PoolManager`.
|
||||
as :class:`urllib3.HTTPConnectionPool` and
|
||||
:class:`urllib3.PoolManager`.
|
||||
|
||||
Provides behavior for making common types of HTTP request methods and
|
||||
decides which type of request field encoding to use.
|
||||
@@ -111,9 +113,9 @@ class RequestMethods(object):
|
||||
the body. This is useful for request methods like POST, PUT, PATCH, etc.
|
||||
|
||||
When ``encode_multipart=True`` (default), then
|
||||
:meth:`urllib3.filepost.encode_multipart_formdata` is used to encode
|
||||
:func:`urllib3.encode_multipart_formdata` is used to encode
|
||||
the payload with the appropriate content type. Otherwise
|
||||
:meth:`urllib.urlencode` is used with the
|
||||
:func:`urllib.parse.urlencode` is used with the
|
||||
'application/x-www-form-urlencoded' content type.
|
||||
|
||||
Multipart encoding must be used when posting files, and it's reasonably
|
||||
@@ -169,3 +171,21 @@ class RequestMethods(object):
|
||||
extra_kw.update(urlopen_kw)
|
||||
|
||||
return self.urlopen(method, url, **extra_kw)
|
||||
|
||||
|
||||
if not six.PY2:
|
||||
|
||||
class RequestModule(sys.modules[__name__].__class__):
|
||||
def __call__(self, *args, **kwargs):
|
||||
"""
|
||||
If user tries to call this module directly urllib3 v2.x style raise an error to the user
|
||||
suggesting they may need urllib3 v2
|
||||
"""
|
||||
raise TypeError(
|
||||
"'module' object is not callable\n"
|
||||
"urllib3.request() method is not supported in this release, "
|
||||
"upgrade to urllib3 v2 to use it\n"
|
||||
"see https://urllib3.readthedocs.io/en/stable/v2-migration-guide.html"
|
||||
)
|
||||
|
||||
sys.modules[__name__].__class__ = RequestModule
|
||||
|
||||
Reference in New Issue
Block a user