Files
PowerToys/PythonHome/Lib/site-packages/requests/adapters.pyc

149 lines
14 KiB
Plaintext
Raw Normal View History

2014-07-09 18:15:23 +08:00
<03>
2014-07-10 23:57:08 +08:00
l<EFBFBD><EFBFBD>Sc@s<>dZddlZddlmZddlmZmZddlmZddl m
2014-07-09 18:15:23 +08:00
Z ddl m Z mZmZmZdd lmZmZmZmZdd
lmZdd lmZdd lmZdd lmZddlmZddlmZ ddl!m"Z"ddl#m$Z$m
Z
mZmZddl%m&Z&e'Z(dZ)dZ*de+fd<00><00>YZ,de,fd<00><00>YZ-dS(s<>
requests.adapters
~~~~~~~~~~~~~~~~~
This module contains the transport adapters that Requests uses to define
and maintain connections.
i<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ni(tResponse(t PoolManagertproxy_from_url(t HTTPResponse(tTimeout(turlparset
basestringt urldefragtunquote(tDEFAULT_CA_BUNDLE_PATHtget_encoding_from_headerstprepend_scheme_if_neededtget_auth_from_url(tCaseInsensitiveDict(t MaxRetryError(t TimeoutError(tSSLError(t HTTPError(t
ProxyError(textract_cookies_to_jar(tConnectionErrorRRR(t_basic_auth_stri
2014-07-10 23:57:08 +08:00
it BaseAdaptercBs)eZdZd<00>Zd<00>Zd<00>ZRS(sThe Base Transport AdaptercCstt|<00>j<00>dS(N(tsuperRt__init__(tself((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyR&scCs
t<00>dS(N(tNotImplementedError(R((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pytsend)scCs
t<00>dS(N(R(R((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pytclose,s(t__name__t
__module__t__doc__RRR(((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyR#s  t HTTPAdaptercBs<>eZdZdddddgZeeeed<00>Zd<00>Zd<00>Z ed <00>Z
2014-07-09 18:15:23 +08:00
d
<00>Z d <00>Z dd <00>Zd <00>Zd<00>Zd<00>Zd<00>Zededdd<00>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 connections and
timeouts, never to requests where the server returns a response.
: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)
t max_retriestconfigt_pool_connectionst _pool_maxsizet _pool_blockcCsc||_i|_i|_tt|<00>j<00>||_||_||_|j ||d|<00>dS(Ntblock(
R!R"t proxy_managerRR RR#R$R%tinit_poolmanager(Rtpool_connectionst pool_maxsizeR!t
2014-07-10 23:57:08 +08:00
pool_block((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyRIs      cst<00>fd<00><00>jD<><00>S(Nc3s'|]}|t<00>|d<00>fVqdS(N(tgetattrtNone(t.0tattr(R(sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pys <genexpr>Ys(tdictt __attrs__(R((RsTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyt __getstate__XscCsbi|_i|_x*|j<00>D]\}}t|||<00>qW|j|j|jd|j<00>dS(NR&(R'R"titemstsetattrR(R#R$R%(RtstateR/tvalue((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyt __setstate__\s   cCs=||_||_||_td|d|d|<00>|_dS(s<>Initializes a urllib3 PoolManager. This method should not be called
2014-07-09 18:15:23 +08:00
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.
2014-07-10 23:57:08 +08:00
t num_poolstmaxsizeR&N(R#R$R%Rt poolmanager(Rt connectionsR9R&((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyR(hs
2014-07-09 18:15:23 +08:00
2014-07-10 23:57:08 +08:00
  cCs<>|j<00>jd<00>ro|rod}|tk r6|}n|sEt}n|sZtd<00><00>nd|_||_nd|_d|_|r<>t|t <00>s<>|d|_
2014-07-09 18:15:23 +08:00
|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
startswithR-tTrueR t Exceptiont cert_reqstca_certst
2014-07-10 23:57:08 +08:00
isinstanceRt cert_filetkey_file(Rtconnturltverifytcerttcert_loc((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyt cert_verifyys"
2014-07-09 18:15:23 +08:00
        cCs<>t<00>}t|dd<00>|_tt|di<00><00>|_t|j<00>|_||_|jj |_ t
|j t <00>r<>|j j d<00>|_ n |j |_ t|j||<00>||_||_|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(RR,R-t status_codeR ROR
tencodingtrawtreasonRERItbytestdecodeRtcookiestrequestt
2014-07-10 23:57:08 +08:00
connection(Rtreqtresptresponse((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pytbuild_response<73>s     c Cs<>|p i}|jt|j<00><00>j<00>}|r<>t|d<00>}|j|<00>}||jkr<>t|d|d|jd|j d|j
2014-07-09 18:15:23 +08:00
<00>|j|<n|j|j |<00>}n*t|<00>}|j <00>}|j j |<00>}|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.
2014-07-10 23:57:08 +08:00
thttpt proxy_headersR8R9R&(tgetRR?tschemeR R^R'RR#R$R%tconnection_from_urltgeturlR:(RRItproxiestproxyR^RHtparsed((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pytget_connection<6F>s"     cCs|jj<00>dS(s<>Disposes of any internal state.
2014-07-09 18:15:23 +08:00
Currently, this just closes the PoolManager, which closes pooled
connections.
2014-07-10 23:57:08 +08:00
N(R:tclear(R((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyR<00>scCsd|p i}t|j<00>j}|j|<00>}|rW|dkrWt|j<00>\}}n |j}|S(sObtain the url to use when making the final request.
2014-07-09 18:15:23 +08:00
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.
2014-07-10 23:57:08 +08:00
R<(RRIR`R_Rtpath_url(RRWRcR`RdRIt_((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyt request_url<72>s  cKsdS(s"Add any headers needed by the connection. As of v2.0 this does
2014-07-09 18:15:23 +08:00
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().
2014-07-10 23:57:08 +08:00
N((RRWtkwargs((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyt add_headerss cCs>i}t|<00>\}}|r:|r:t||<00>|d<n|S(s3Returns a dictionary of the headers to add to any request sent
2014-07-09 18:15:23 +08:00
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.
2014-07-10 23:57:08 +08:00
sProxy-Authorization(R R(RRdROtusernametpassword((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyR^s  cCs |j|j|<00>}|j||j||<00>|j||<00>}|j|<00>|jdkphd|jk } td|d|<00>}y<>| s<>|j d|j
2014-07-09 18:15:23 +08:00
d|d|jd|jdt d t d
t d t d |j d |<00>
}
nIt |d<00>r<>|j}n|jd |<00>} y<>| j|j
|dt<00>x-|jj<00>D]\} } | j| | <00>q:W| j<00>x^|jD]S}| jtt|<00><00>djd<00><00>| jd<00>| j|<00>| jd<00>qnW| jd<00>| j<00>}tj|d|d| d
t d t <00>}
Wn| j<00><01>nX|j| <00>Wn<57>tjk
rU}t |d|<00><01>n<>t!k
ry}t |d|<00><01>n<>t"k
r<>}t#|<00><00>ndt$t%fk
r<>}t&|t$<00>r<>t'|d|<00><01>q<>t&|t(<00>r<>t)|d|<00><01>q<><02>nX|j*||
<00>S(sSends 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) The timeout on the request.
: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-LengthtconnecttreadtmethodRItbodyROtredirecttassert_same_hosttpreload_contenttdecode_contenttretriesttimeoutt
proxy_pooltskip_accept_encodingisutf-8s
s0
tpoolRXRWN(+RfRIRMRjRlRrR-ROt TimeoutSauceturlopenRqtFalseR!thasattrRyt _get_connt
putrequestRAR3t putheadert
endheadersRthextlentencodet getresponseRt from_httplibRt _put_conntsocketterrorRRt _ProxyErrorRt _SSLErrort
2014-07-10 23:57:08 +08:00
_HTTPErrorRERRRR\(RRWtstreamRxRJRKRcRHRItchunkedRZtlow_conntheaderR6titrtsockerrte((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyR&sv          
2014-07-09 18:15:23 +08:00
&     
2014-07-10 23:57:08 +08:00
N(RRRR1tDEFAULT_POOLSIZEtDEFAULT_RETRIEStDEFAULT_POOLBLOCKRR2R7R(RMR\R-RfRRjRlR^R~RAR(((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyR 0s"     % $    (.RR<>tmodelsRtpackages.urllib3.poolmanagerRRtpackages.urllib3.responseRtpackages.urllib3.utilRR|tcompatRRRRtutilsR R
2014-07-09 18:15:23 +08:00
R R t
structuresR tpackages.urllib3.exceptionsRRRR<>RR<>RR<>RVRt
2014-07-10 23:57:08 +08:00
exceptionsRtauthRR~R<>R<>R<>tobjectRR (((sTe:\github\Wox.JSONRPC\Output\Debug\PythonHome\lib\site-packages\requests\adapters.pyt<module> s* """