Spade
Mini Shell
| Directory:~$ /proc/self/root/lib/python2.7/site-packages/requests/ |
| [Home] [System Details] [Kill Me] |
�
�^c@s�dZddlZddlmZddlmZmZddlmZddl m
Zddlm
Z
dd lmZmZdd
lmZmZmZmZmZddlmZddlmZdd
lmZddlmZddlmZddlm
Z
ddlm!Z!ddlm"Z#ddlm$Z$ddl%m&Z&ddl'm(Z(m)Z)m*Z*m"Z"mZm+Z+ddl,m-Z-e.Z/dZ0dZ1de2fd��YZ3de3fd��YZ4dS(s�
requests.adapters
~~~~~~~~~~~~~~~~~
This module contains the transport adapters that Requests uses to define
and maintain connections.
i����Ni(tResponse(tPoolManagertproxy_from_url(tHTTPResponse(tTimeout(tRetry(turlparset
basestring(tDEFAULT_CA_BUNDLE_PATHtget_encoding_from_headerstprepend_scheme_if_neededtget_auth_from_urlt
urldefragauth(tCaseInsensitiveDict(tConnectTimeoutError(t HTTPError(t
MaxRetryError(t
ProxyError(t
ProtocolError(tReadTimeoutError(tSSLError(t
ResponseError(textract_cookies_to_jar(tConnectionErrortConnectTimeouttReadTimeoutRRt
RetryError(t_basic_auth_stri
itBaseAdaptercBs)eZdZd�Zd�Zd�ZRS(sThe Base Transport
AdaptercCstt|�j�dS(N(tsuperRt__init__(tself((s5/usr/lib/python2.7/site-packages/requests/adapters.pyR+scCs
t�dS(N(tNotImplementedError(R((s5/usr/lib/python2.7/site-packages/requests/adapters.pytsend.scCs
t�dS(N(R
(R((s5/usr/lib/python2.7/site-packages/requests/adapters.pytclose1s(t__name__t
__module__t__doc__RR!R"(((s5/usr/lib/python2.7/site-packages/requests/adapters.pyR(s tHTTPAdaptercBs�eZdZdddddgZeeeed�Zd�Zd�Z ed �Z
d
�Zd�Zd�Z
dd
�Zd�Zd�Zd�Zd�Zededdd�ZRS(s�The
built-in HTTP Adapter for urllib3.
Provides a general-case interface for Requests sessions to contact HTTP
and
HTTPS urls by implementing the Transport Adapter interface. This class
will
usually be created by the :class:`Session <Session>` class under
the
covers.
:param pool_connections: The number of urllib3 connection pools to
cache.
:param pool_maxsize: The maximum number of connections to save in the
pool.
:param int max_retries: The maximum number of retries each connection
should attempt. Note, this applies only to failed DNS lookups,
socket
connections and connection timeouts, never to requests where data
has
made it to the server. By default, Requests does not retry failed
connections. If you need granular control over the conditions under
which we retry a request, import urllib3's ``Retry`` class and
pass
that instead.
:param pool_block: Whether the connection pool should block for
connections.
Usage::
>>> import requests
>>> s = requests.Session()
>>> a = requests.adapters.HTTPAdapter(max_retries=3)
>>> s.mount('http://', a)
tmax_retriestconfigt_pool_connectionst
_pool_maxsizet_pool_blockcCs�|tkr$tddt�|_ntj|�|_i|_i|_tt|�j �||_
||_||_|j
||d|�dS(Nitreadtblock(tDEFAULT_RETRIESRtFalseR'tfrom_intR(t
proxy_managerRR&RR)R*R+tinit_poolmanager(Rtpool_connectionstpool_maxsizeR't
pool_block((s5/usr/lib/python2.7/site-packages/requests/adapters.pyRRs cst�fd��jD��S(Nc3s'|]}|t�|d�fVqdS(N(tgetattrtNone(t.0tattr(R(s5/usr/lib/python2.7/site-packages/requests/adapters.pys <genexpr>es(tdictt __attrs__(R((Rs5/usr/lib/python2.7/site-packages/requests/adapters.pyt__getstate__dscCsbi|_i|_x*|j�D]\}}t|||�qW|j|j|jd|j�dS(NR-(R1R(titemstsetattrR2R)R*R+(RtstateR9tvalue((s5/usr/lib/python2.7/site-packages/requests/adapters.pyt__setstate__hs c
KsF||_||_||_td|d|d|dt|�|_dS(sInitializes a urllib3
PoolManager.
This method should not be called from user code, and is only
exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param connections: The number of urllib3 connection pools to
cache.
:param maxsize: The maximum number of connections to save in the
pool.
:param block: Block when no free connections are available.
:param pool_kwargs: Extra keyword arguments used to initialize the
Pool Manager.
t num_poolstmaxsizeR-tstrictN(R)R*R+RtTruetpoolmanager(RtconnectionsRCR-tpool_kwargs((s5/usr/lib/python2.7/site-packages/requests/adapters.pyR2ts
cKsc||jkrX|j|�}t|d|d|jd|jd|j|�|j|<n|j|S(s�Return
urllib3 ProxyManager for the given proxy.
This method should not be called from user code, and is only
exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param proxy: The proxy to return a urllib3 ProxyManager for.
:param proxy_kwargs: Extra keyword arguments used to configure the
Proxy Manager.
:returns: ProxyManager
t
proxy_headersRBRCR-(R1RIRR)R*R+(Rtproxytproxy_kwargsRI((s5/usr/lib/python2.7/site-packages/requests/adapters.pytproxy_manager_for�s cCs�|j�jd�ro|rod}|tk r6|}n|sEt}n|sZtd��nd|_||_nd|_d|_|r�t|t �s�|d|_
|d|_q�||_
ndS(s�Verify a SSL certificate. This method should not be called from
user
code, and is only exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param conn: The urllib3 connection object associated with the
cert.
:param url: The requested URL.
:param verify: Whether we should actually verify the certificate.
:param cert: The SSL certificate to verify.
thttpss4Could not find a suitable SSL CA certificate
bundle.t
CERT_REQUIREDt CERT_NONEiiN(tlowert
startswithR7RERt Exceptiont cert_reqstca_certst
isinstanceRt cert_filetkey_file(Rtconnturltverifytcerttcert_loc((s5/usr/lib/python2.7/site-packages/requests/adapters.pytcert_verify�s"
cCs�t�}t|dd�|_tt|di��|_t|j�|_||_|jj |_ t
|jt�r�|jj
d�|_n|j|_t|j||�||_||_|S(s�Builds
a :class:`Response <requests.Response>` object from a urllib3
response. This should not be called from user code, and is only
exposed
for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`
:param req: The :class:`PreparedRequest <PreparedRequest>`
used to generate the response.
:param resp: The urllib3 response object.
tstatustheaderssutf-8N(RR6R7tstatus_codeR
R_R tencodingtrawtreasonRURYtbytestdecodeRtcookiestrequestt
connection(Rtreqtresptresponse((s5/usr/lib/python2.7/site-packages/requests/adapters.pytbuild_response�s cCs�|p i}|jt|j��j�}|r`t|d�}|j|�}|j|�}n*t|�}|j�}|jj|�}|S(seReturns
a urllib3 connection for the given URL. This should not be
called from user code, and is only exposed for use when subclassing
the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param url: The URL to connect to.
:param proxies: (optional) A Requests-style dictionary of proxies
used on this request.
thttp( tgetRRPtschemeR
RLtconnection_from_urltgeturlRF(RRYtproxiesRJR1RXtparsed((s5/usr/lib/python2.7/site-packages/requests/adapters.pytget_connection�scCs|jj�dS(s�Disposes
of any internal state.
Currently, this just closes the PoolManager, which closes pooled
connections.
N(RFtclear(R((s5/usr/lib/python2.7/site-packages/requests/adapters.pyR"�scCs^|p i}t|j�j}|j|�}|rQ|dkrQt|j�}n |j}|S(sObtain
the url to use when making the final request.
If the message is being sent through a HTTP proxy, the full URL has
to
be used. Otherwise, we should only use the path portion of the URL.
This should not be called from user code, and is only exposed for
use
when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param request: The :class:`PreparedRequest
<PreparedRequest>` being sent.
:param proxies: A dictionary of schemes to proxy URLs.
RM(RRYRoRnRtpath_url(RRgRrRoRJRY((s5/usr/lib/python2.7/site-packages/requests/adapters.pytrequest_urls
cKsdS(s"Add
any headers needed by the connection. As of v2.0 this does
nothing by default, but is left for overriding by users that
subclass
the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
This should not be called from user code, and is only exposed for
use
when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param request: The :class:`PreparedRequest
<PreparedRequest>` to add headers to.
:param kwargs: The keyword arguments from the call to send().
N((RRgtkwargs((s5/usr/lib/python2.7/site-packages/requests/adapters.pytadd_headersscCs>i}t|�\}}|r:|r:t||�|d<n|S(s3Returns
a dictionary of the headers to add to any request sent
through a proxy. This works with urllib3 magic to ensure that they
are
correctly sent to the proxy, rather than in a tunnelled request if
CONNECT is being used.
This should not be called from user code, and is only exposed for
use
when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param proxies: The url of the proxy being used for this request.
:param kwargs: Optional additional keyword arguments.
sProxy-Authorization(RR(RRJR_tusernametpassword((s5/usr/lib/python2.7/site-packages/requests/adapters.pyRI-s
cCs�|j|j|�}|j||j||�|j||�}|j|�|jdkphd|jk} t|t �r�y%|\}
}t
d|
d|�}Wq�tk
r�}dj|�}
t|
��q�Xnt
d|d|�}y�| sI|j
d|jd|d|jd|jd td
tdtdtd
|jd|�
}nIt|d�rd|j}n|jd|�}y�|j|j|dt�x-|jj�D]\}}|j||�q�W|j�x^|jD]S}|jtt|��djd��|jd�|j|�|jd�q�W|jd�|j�}tj|d|d|dtdt�}Wn|j
��nX|j!|�Wn!t"t#j$fk
r�}
t%|
d|��n�t&k
r5}t|j't(�r�t)|d|��nt|j't*�r
t+|d|��nt%|d|��n�t,k
rS}t-|��ndt.t/fk
r�}t|t.�r�t0|d|��q�t|t1�r�t2|d|��q��nX|j3||�S(s�Sends
PreparedRequest object. Returns Response object.
:param request: The :class:`PreparedRequest
<PreparedRequest>` being sent.
:param stream: (optional) Whether to stream the request content.
:param timeout: (optional) How long to wait for the server to send
data before giving up, as a float, or a (`connect timeout, read
timeout <user/advanced.html#timeouts>`_) tuple.
:type timeout: float or tuple
:param verify: (optional) Whether to verify SSL certificates.
:param cert: (optional) Any user-provided SSL certificate to be
trusted.
:param proxies: (optional) The proxies dictionary to apply to the
request.
sContent-LengthtconnectR,ssInvalid timeout {0}. Pass a (connect,
read) timeout tuple, or a single float to set both timeouts to the same
valuetmethodRYtbodyR_tredirecttassert_same_hosttpreload_contenttdecode_contenttretriesttimeoutt
proxy_pooltskip_accept_encodingisutf-8s
s0
tpoolRhRgN(4RtRYR]RwRyR~R7R_RUttupletTimeoutSaucet
ValueErrortformatturlopenR}R/R'thasattrR�t _get_connt
putrequestRER=t putheadert
endheadersR!thextlentencodetgetresponseRtfrom_httplibR"t _put_connRtsocketterrorRRRcRRRRt_ProxyErrorRt _SSLErrort
_HTTPErrorRRRRl(RRgtstreamR�RZR[RrRXRYtchunkedR|R,teterrRjtlow_conntheaderR@titr((s5/usr/lib/python2.7/site-packages/requests/adapters.pyR!Cs�
&
N(R#R$R%R;tDEFAULT_POOLSIZER.tDEFAULT_POOLBLOCKRR<RAR2RLR]RlR7RtR"RwRyRIR/RER!(((s5/usr/lib/python2.7/site-packages/requests/adapters.pyR&5s$ % $ (5R%R�tmodelsRturllib3.poolmanagerRRturllib3.responseRturllib3.utilRR�turllib3.util.retryRtcompatRRtutilsRR R
RRt
structuresR
turllib3.exceptionsRRR�RRR�RRRR�RRfRt
exceptionsRRRRtauthRR/R�R�R.tobjectRR&(((s5/usr/lib/python2.7/site-packages/requests/adapters.pyt<module> s2(.