/usr/lib/python2.7/site-packages/requests
NameSizeModeActions
adapters.py213440644editdlrm
adapters.pyc190880644editdlrm
adapters.pyo190880644editdlrm
api.py62530644editdlrm
api.pyc69680644editdlrm
api.pyo69680644editdlrm
auth.py102060644editdlrm
auth.pyc102240644editdlrm
auth.pyo102240644editdlrm
certs.py7090644editdlrm
certs.pyc9790644editdlrm
certs.pyo9790644editdlrm
compat.py16780644editdlrm
compat.pyc19870644editdlrm
compat.pyo19870644editdlrm
cookies.py184300644editdlrm
cookies.pyc220490644editdlrm
cookies.pyo220490644editdlrm
exceptions.py31850644editdlrm
exceptions.pyc68580644editdlrm
exceptions.pyo68580644editdlrm
help.py35150644editdlrm
help.pyc32660644editdlrm
help.pyo32660644editdlrm
hooks.py7570644editdlrm
hooks.pyc11620644editdlrm
hooks.pyo11620644editdlrm
models.py342090644editdlrm
models.pyc287100644editdlrm
models.pyo287100644editdlrm
packages.py5420644editdlrm
packages.pyc4590644editdlrm
packages.pyo4590644editdlrm
sessions.py295250644editdlrm
sessions.pyc224790644editdlrm
sessions.pyo224790644editdlrm
status_codes.py41290644editdlrm
status_codes.pyc59820644editdlrm
status_codes.pyo59820644editdlrm
structures.py29810644editdlrm
structures.pyc51600644editdlrm
structures.pyo51600644editdlrm
utils.py300380644editdlrm
utils.pyc268580644editdlrm
utils.pyo268580644editdlrm
_internal_utils.py10960644editdlrm
_internal_utils.pyc14990644editdlrm
_internal_utils.pyo14470644editdlrm
__init__.py36080644editdlrm
__init__.pyc37990644editdlrm
__init__.pyo36300644editdlrm
__version__.py4360644editdlrm
__version__.pyc5750644editdlrm
__version__.pyo5750644editdlrm
Edit: /usr/lib/python2.7/site-packages/requests/sessions.pyo (22479B)
 /ec@sdZddlZddlZddlZddlmZddlmZddlm Z m Z m Z m Z m Z mZddlmZmZmZmZddlmZmZmZdd lmZmZdd lmZdd lmZmZm Z dd l!m"Z"m#Z#m$Z$m%Z%dd l&m'Z'ddl(m)Z)ddlm*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1ddlm2Z2ej3dkry ej4Z5Wne6k rej7Z5nXn ejZ5e dZ8e dZ9de:fdYZ;de;fdYZ<dZ=dS(s requests.session ~~~~~~~~~~~~~~~~ This module provides a Session object to manage and persist settings across requests (cookies, auth, proxies). iN(t timedeltai(t_basic_auth_str(t cookielibtis_py3t OrderedDictturljointurlparsetMapping(tcookiejar_from_dicttextract_cookies_to_jartRequestsCookieJart merge_cookies(tRequesttPreparedRequesttDEFAULT_REDIRECT_LIMIT(t default_hookst dispatch_hook(tto_native_string(tto_key_val_listtdefault_headerst DEFAULT_PORTS(tTooManyRedirectst InvalidSchematChunkedEncodingErrortContentDecodingError(tCaseInsensitiveDict(t HTTPAdapter(t requote_uritget_environ_proxiestget_netrc_authtshould_bypass_proxiestget_auth_from_urlt rewind_body(tcodes(tREDIRECT_STATItwin32cCs|dkr|S|dkr |St|to;t|tsB|S|t|}|jt|g|jD]\}}|dkrt|^qt}x|D] }||=qW|S(sDetermines appropriate setting for a given request, taking into account the explicit setting on that request, and the setting in the session. If a setting is a dictionary, they will be merged together using `dict_class` N(tNonet isinstanceRRtupdatetitems(trequest_settingtsession_settingt dict_classtmerged_settingtktvt none_keystkey((s5/usr/lib/python2.7/site-packages/requests/sessions.pyt merge_setting1s  1  cCsZ|dks!|jdgkr%|S|dksF|jdgkrJ|St|||S(sProperly merges both requests and session hooks. This is necessary because when request_hooks == {'response': []}, the merge breaks Session hooks entirely. tresponseN(R$tgetR0(t request_hookst session_hooksR*((s5/usr/lib/python2.7/site-packages/requests/sessions.pyt merge_hooksPs !!tSessionRedirectMixincBsPeZdZdZededdedZdZdZ dZ RS(cCs?|jr;|jd}tr.|jd}nt|dSdS(s7Receives a Response. Returns a redirect URI or ``None``tlocationtlatin1tutf8N(t is_redirecttheadersRtencodeRR$(tselftrespR7((s5/usr/lib/python2.7/site-packages/requests/sessions.pytget_redirect_targetas    cCst|}t|}|j|jkr.tS|jdkrn|jdkrn|jdkrn|jdkrntS|j|jk}|j|jk}tj|jddf}| r|j|kr|j|krtS|p|S(sFDecide whether Authorization header should be removed when redirectingthttpiPthttpsiN(iPN(iN( RthostnametTruetschemetportR$tFalseRR2(R=told_urltnew_urlt old_parsedt new_parsedt changed_porttchanged_schemet default_port((s5/usr/lib/python2.7/site-packages/requests/sessions.pytshould_strip_authvs  c ks9g} |j|} t|jj} x | r4|j} | j|| d|_y |jWn-tt t fk r|j j dt nXt|j|jkrtd|jd|n|j| jdr t|j}dt|j| f} nt| }|jdkr?| r?|jd| }n|jrT|j} n|j} |jst|jt| } n t| } t| | _|j| ||jtjtjfkrd}x!|D]}| jj |dqWd| _"n| j}y |d =Wnt#k r'nXt$| j%||j t&| j%|j'| j(| j%|j)| |}|j*| || j+dk od |kpd |k}|rt,| n| }|r|Vq*|j-|d |d|d|d|d|dt | }t$|j'| |j |j|} |Vq*WdS(sBReceives a Response. Returns a generator of Responses or Requests.itdecode_contentsExceeded %s redirects.R1s//s%s:%sttfragmentsContent-Lengths Content-TypesTransfer-EncodingtCookietstreamttimeouttverifytcerttproxiestallow_redirectsN(sContent-Lengths Content-TypesTransfer-Encoding(.R?RturlRQtcopytappendthistorytcontentRRt RuntimeErrortrawtreadRFtlent max_redirectsRtcloset startswithRRDt_replacetgeturltnetlocRRtrebuild_methodt status_codeR!ttemporary_redirecttpermanent_redirectR;tpopR$tbodytKeyErrorR t_cookiesR tcookiestprepare_cookiestrebuild_proxiest rebuild_autht_body_positionR tsend(R=R>treqRSRTRURVRWtyield_requeststadapter_kwargsthistRYtprevious_fragmenttprepared_requestt parsed_rurltparsedtpurged_headerstheaderR;t rewindable((s5/usr/lib/python2.7/site-packages/requests/sessions.pytresolve_redirectss|                   cCs{|j}|j}d|kr@|j|jj|r@|d=n|jrUt|nd}|dk rw|j|ndS(sWhen being redirected we may want to strip authentication from the request to avoid leaking credentials. This method intelligently removes and reapplies authentication where possible to avoid credential loss. t AuthorizationN(R;RYRNtrequestt trust_envRR$t prepare_auth(R=R{R1R;RYtnew_auth((s5/usr/lib/python2.7/site-packages/requests/sessions.pyRss  $  c CsE|dk r|ni}|j}|j}t|j}|j}|jd}t|d|}|jr| rt |d|} | j|| jd} | r|j || qnd|kr|d=nyt ||\} } Wnt k rd\} } nX|j d rA| rA| rAt| | |d>> import requests >>> s = requests.Session() >>> s.get('https://httpbin.org/get') Or as a context manager:: >>> with requests.Session() as s: >>> s.get('https://httpbin.org/get') R;RptauthRWthookstparamsRURVtprefetchtadaptersRSRRbcCst|_d|_i|_t|_i|_t|_ t |_ d|_ t |_t |_ti|_t|_|jdt|jdtdS(Nshttps://shttp://(RR;R$RRWRRRRFRSRCRURVRRbRRRpRRtmountR(R=((s5/usr/lib/python2.7/site-packages/requests/sessions.pyt__init__os           cCs|S(N((R=((s5/usr/lib/python2.7/site-packages/requests/sessions.pyt __enter__scGs|jdS(N(Rc(R=targs((s5/usr/lib/python2.7/site-packages/requests/sessions.pyt__exit__scCs*|jp i}t|tjs0t|}nttt|j|}|j}|jr| r|j rt |j }nt }|j d|j jd|j d|jd|jd|jdt|j|jdtdt|j|jd t||jd |d t|j|j |S( sConstructs a :class:`PreparedRequest ` for transmission and returns it. The :class:`PreparedRequest` has settings merged from the :class:`Request ` instance and those of the :class:`Session`. :param request: :class:`Request` instance to prepare with this session's settings. :rtype: requests.PreparedRequest RRYtfilestdatatjsonR;R*RRRpR(RpR%Rt CookieJarRR R RRRRYR tprepareRtupperRRRR0R;RRR5R(R=RRptmerged_cookiesRtp((s5/usr/lib/python2.7/site-packages/requests/sessions.pytprepare_requests*        cCstd|jd|d|d|d|p-id|d|p?id|d |d | }|j|}| poi} |j|j| | ||}i| d 6| d 6}|j||j||}|S( sConstructs a :class:`Request `, prepares it and sends it. Returns :class:`Response ` object. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json to send in the body of the :class:`Request`. :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`. :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`. :param files: (optional) Dictionary of ``'filename': file-like-objects`` for multipart encoding upload. :param auth: (optional) Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth. :param timeout: (optional) How long to wait for the server to send data before giving up, as a float, or a :ref:`(connect timeout, read timeout) ` tuple. :type timeout: float or tuple :param allow_redirects: (optional) Set to True by default. :type allow_redirects: bool :param proxies: (optional) Dictionary mapping protocol or protocol and hostname to the URL of the proxy. :param stream: (optional) whether to immediately download the response content. Defaults to ``False``. :param verify: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to ``True``. :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair. :rtype: requests.Response RRYR;RRRRRRpRRTRX(R RRtmerge_environment_settingsRYR&Ru(R=RRYRRR;RpRRRTRXRWRRSRURVRRvtpreptsettingst send_kwargsR>((s5/usr/lib/python2.7/site-packages/requests/sessions.pyRs*)       cKs#|jdt|jd||S(sSends a GET request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response RXR(RRCR(R=RYtkwargs((s5/usr/lib/python2.7/site-packages/requests/sessions.pyR2scKs#|jdt|jd||S(sSends a OPTIONS request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response RXtOPTIONS(RRCR(R=RYR((s5/usr/lib/python2.7/site-packages/requests/sessions.pytoptions&scKs#|jdt|jd||S(sSends a HEAD request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response RXR(RRFR(R=RYR((s5/usr/lib/python2.7/site-packages/requests/sessions.pythead1scKs|jd|d|d||S(sSends a POST request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param json: (optional) json to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response RRR(R(R=RYRRR((s5/usr/lib/python2.7/site-packages/requests/sessions.pytpost<s cKs|jd|d||S(suSends a PUT request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response tPUTR(R(R=RYRR((s5/usr/lib/python2.7/site-packages/requests/sessions.pytputIs cKs|jd|d||S(swSends a PATCH request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response tPATCHR(R(R=RYRR((s5/usr/lib/python2.7/site-packages/requests/sessions.pytpatchUs cKs|jd||S(sSends a DELETE request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :rtype: requests.Response tDELETE(R(R=RYR((s5/usr/lib/python2.7/site-packages/requests/sessions.pytdeleteasc Ks|jd|j|jd|j|jd|j|jd|jt|trjtdn|jdt }|j d}|j }|j d|j }t}|j||}t|} td| |_td |||}|jr1x-|jD]} t|j| j| jq Wnt|j||j|j|||} |r{g| D]} | ^qing} | r| jd || j}| |_n|sy(t|j||d t ||_Wqtk rqXn|s|jn|S( sISend a given PreparedRequest. :rtype: requests.Response RSRURVRWs#You can only send PreparedRequests.RXRYtsecondsR1iRw(RRSRURVRWR%R t ValueErrorRlRCR2Rt get_adapterRYtpreferred_clockRuRtelapsedRR\R RpRR_Rtinserttnextt_nextt StopIterationR]( R=RRRXRSRtadaptertstarttrRR>tgenR\((s5/usr/lib/python2.7/site-packages/requests/sessions.pyRuksB     %  (  c Cs|jr|dk r$|jdnd}t|d|}x*|jD]\}} |j|| qIW|tks|dkrtjjdptjjd}qnt ||j }t ||j }t ||j }t ||j }i|d6|d6|d6|d6S( s^ Check the environment and merge it with some settings. :rtype: dict RtREQUESTS_CA_BUNDLEtCURL_CA_BUNDLERURWRSRVN(RR$R2RR'RRCtostenvironR0RWRSRURV( R=RYRWRSRURVRt env_proxiesR,R-((s5/usr/lib/python2.7/site-packages/requests/sessions.pyRs !cCsSx<|jjD]+\}}|jj|jr|SqWtd|dS(s~ Returns the appropriate connection adapter for the given URL. :rtype: requests.adapters.BaseAdapter s*No connection adapters were found for '%s'N(RR'tlowerRdR(R=RYtprefixR((s5/usr/lib/python2.7/site-packages/requests/sessions.pyRscCs(x!|jjD]}|jqWdS(s+Closes all adapters and as such the sessionN(RtvaluesRc(R=R-((s5/usr/lib/python2.7/site-packages/requests/sessions.pyRcscCso||j|s (t __attrs__(R=tstate((R=s5/usr/lib/python2.7/site-packages/requests/sessions.pyt __getstate__scCs1x*|jD]\}}t|||q WdS(N(R'tsetattr(R=RRtvalue((s5/usr/lib/python2.7/site-packages/requests/sessions.pyt __setstate__sN(RRt__doc__RRRRRR$RCRR2RRRRRRRuRRRcRRR(((s5/usr/lib/python2.7/site-packages/requests/sessions.pyRVs2  7   ) D  I    cCstS(sZ Returns a :class:`Session` for context-management. .. deprecated:: 1.0.0 This method has been deprecated since version 1.0.0 and is only kept for backwards compatibility. New code should use :class:`~requests.sessions.Session` to create a session. This may be removed at a future date. :rtype: Session (R(((s5/usr/lib/python2.7/site-packages/requests/sessions.pytsessions (>RRtsysttimetdatetimeRRRtcompatRRRRRRRpRR R R tmodelsR R RRRRt_internal_utilsRtutilsRRRt exceptionsRRRRt structuresRRRRRRRRR t status_codesR!R"tplatformt perf_counterRtAttributeErrortclockR0R5tobjectR6RR(((s5/usr/lib/python2.7/site-packages/requests/sessions.pyt s:   ."".