Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/requests_toolbelt/adapters/ |
| [Home] [System Details] [Kill Me] |
�
ӵ
Yc@s�dZddlZddlZddlmZddlmZddlmZddlm Z ddlm
Z
d ejfd
��YZdeejfd��YZ
d
e
fd��YZdefd��YZdefd��YZed�Zd�ZdS(sThe
App Engine Transport Adapter for requests.
.. versionadded:: 0.6.0
This requires a version of requests >= 2.10.0 and Python 2.
There are two ways to use this library:
#. If you're using requests directly, you can use code like:
.. code-block:: python
>>> import requests
>>> import ssl
>>> import requests.packages.urllib3.contrib.appengine as
ul_appengine
>>> from requests_toolbelt.adapters import appengine
>>> s = requests.Session()
>>> if ul_appengine.is_appengine_sandbox():
... s.mount('http://', appengine.AppEngineAdapter())
... s.mount('https://', appengine.AppEngineAdapter())
#. If you depend on external libraries which use requests, you can use code
like:
.. code-block:: python
>>> from requests_toolbelt.adapters import appengine
>>> appengine.monkeypatch()
which will ensure all requests.Session objects use AppEngineAdapter
properly.
You are also able to :ref:`disable certificate validation
<insecure_appengine>`
when monkey-patching.
i����N(tadapters(tsessionsi(t
exceptions(t
gaecontrib(ttimeouttAppEngineMROHackcBseZdZeZd�ZRS(s�Resolves
infinite recursion when monkeypatching.
This works by injecting itself as the base class of both the
:class:`AppEngineAdapter` and Requests' default HTTPAdapter, which
needs to
be done because default HTTPAdapter's MRO is recompiled when we
monkeypatch, at which point this class becomes HTTPAdapter's base
class.
In addition, we use an instantiation flag to avoid infinite recursion.
cOs2|js.t|_tt|�j||�ndS(N(t_initializedtTruetsuperRt__init__(tselftargstkwargs((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyR 9s (t__name__t
__module__t__doc__tFalseRR (((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyR.stAppEngineAdaptercBs9eZdZejjdgZed�Zed�Z RS(syThe
transport adapter for Requests to use urllib3's GAE support.
Implements Requests's HTTPAdapter API.
When deploying to Google's App Engine service, some of
Requests'
functionality is broken. There is underlying support for GAE in
urllib3.
This functionality, however, is opt-in and needs to be enabled
explicitly
for Requests to be able to use it.
t_validate_certificatecOs-t�||_tt|�j||�dS(N(t_check_versionRRRR (R
tvalidate_certificateRR((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyR Ls cCst|j�|_dS(N(t_AppEnginePoolManagerRtpoolmanager(R
tconnectionstmaxsizetblock((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pytinit_poolmanagerQs(
R
RRRtHTTPAdaptert __attrs__RR RR(((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyR?s tInsecureAppEngineAdaptercBseZdZd�ZRS(s�An
always-insecure GAE adapter for Requests.
This is a variant of the the transport adapter for Requests to use
urllib3's GAE support that does not validate certificates. Use
with
caution!
.. note::
The ``validate_certificate`` keyword argument will not be honored
here
and is not part of the signature because we always force it to
``False``.
See :class:`AppEngineAdapter` for further details.
cOsK|jdt�r(tjdtj�ntt|�jdt||�dS(NRs�Certificate
validation cannot be specified on the InsecureAppEngineAdapter, but was
present. This will be ignored and certificate validation will remain
off.( tpopRtwarningstwarntexct
IgnoringGAECertificateValidationRRR (R
RR((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyR ds
(R
RRR (((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyRUs
RcBs,eZdZed�Zd�Zd�ZRS(sKImplements
urllib3's PoolManager API expected by requests.
While a real PoolManager map hostnames to reusable Connections,
AppEngine has no concept of a reusable connection to a host.
So instead, this class constructs a small Connection per request,
that is returned to the Adapter and used to access the URL.
cCstjd|�|_dS(NR(RtAppEngineManagertappengine_manager(R
R((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyR xs cCst|j|�S(N(t_AppEngineConnectionR$(R
turl((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pytconnection_from_url|scCsdS(N((R
((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pytclears(R
RRRR R'R((((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyRos R%c Bs>eZdZd�Zdddeeejjddd�Z RS(s�Implements
urllib3's HTTPConnectionPool API's urlopen().
This Connection's urlopen() is called with a host-relative path,
so in order to properly support opening the URL, we need to store
the full URL when this Connection is constructed from the PoolManager.
This code wraps AppEngineManager.urlopen(), which exposes a different
API than in the original urllib3 urlopen(), and thus needs this
adapter.
cCs||_||_dS(N(R$R&(R
R$R&((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyR �s cKsX|js!|jp|j|_n|jj||jd|d|d|d|d||�S(NtbodytheaderstretriestredirectR(ttotalt_readt_connectR$turlopenR&(R
tmethodR&R)R*R+R,tassert_same_hostRtpool_timeouttrelease_conntresponse_kw((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyR0�s N(
R
RRR tNoneRRtTimeouttDEFAULT_TIMEOUTR0(((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyR%�s cCs2t�t}|st}n|t_|t_dS(s�Sets
up all Sessions to use AppEngineAdapter by default.
If you don't want to deal with configuring your own Sessions,
or if you use libraries that use requests directly (ie requests.post),
then you may prefer to monkeypatch and auto-configure all Sessions.
.. warning: :
If ``validate_certificate`` is ``False``, certification validation
will
effectively be disabled for all requests.
N(RRRRRR(Rtadapter((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pytmonkeypatch�s cCs.tdkr*tjdjtj���ndS(Ns^The
toolbelt requires at least Requests 2.10.0 to be installed. Version {0} was
found
instead.(RR6R!tVersionMismatchErrortformattrequestst__version__(((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyR�s(RR=RRRtRR!t_compatRRRRRRtobjectRR%RR:R(((sH/usr/lib/python2.7/site-packages/requests_toolbelt/adapters/appengine.pyt<module>#s,