ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ m"[c@sdZddlZddlZddlZddlmZddlmZddlm Z m Z m Z m Z m Z mZddlmZmZmZmZddlmZmZmZdd lmZmZdd lmZdd lmZmZdd 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.ddl/m0Z0ddlm1Z1ej2dkry ej3Z4Wne5k rej6Z4nXn ejZ4e dZ7e dZ8de9fdYZ: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_headers(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((sB/opt/alt/python27/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#tgetR/(t request_hookst session_hooksR)((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyt merge_hooksPs !!tSessionRedirectMixincBsGeZdZededdedZdZdZdZ RS(cCs?|jr;|jd}tr.|jd}nt|dSdS(s7Receives a Response. Returns a redirect URI or ``None``tlocationtlatin1tutf8N(t is_redirecttheadersRtencodeRR#(tselftrespR6((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pytget_redirect_targetas    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.R0s//s%s:%sttfragmentsContent-Lengths Content-TypesTransfer-EncodingtCookietstreamttimeouttverifytcerttproxiestallow_redirectsN(sContent-Lengths Content-TypesTransfer-Encoding(.R>RturlRAtcopytappendthistorytcontentRRt RuntimeErrortrawtreadtFalsetlent max_redirectsRtcloset startswithRtschemet_replacetgeturltnetlocRRtrebuild_methodt status_codeR ttemporary_redirecttpermanent_redirectR:tpopR#tbodytKeyErrorR t_cookiesR tcookiestprepare_cookiestrebuild_proxiest rebuild_autht_body_positionRtsend(R<R=treqRCRDRERFRGtyield_requeststadapter_kwargsthistRItprevious_fragmenttprepared_requestt parsed_rurltparsedtpurged_headerstheaderR:t rewindable((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pytresolve_redirectsvs|                   cCs|j}|j}d|kr[t|jj}t|}|j|jkr[|d=q[n|jrpt|nd}|dk r|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:RIRtrequestthostnamet trust_envRR#t prepare_auth(R<RmR0R:RItoriginal_parsedtredirect_parsedtnew_auth((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyRes      c Cs5|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| r1| r1t | | |dRQR#tTrueRsReRdRZ(((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyR5_s  p  )tSessioncBseZdZddddddddd d d d d g ZdZdZdZdZd!d!d!d!d!d!d!e d!d!d!d!d!d!dZ dZ dZ dZ d!d!dZd!dZd!dZdZdZdZdZdZdZdZd ZRS("s~A Requests session. Provides cookie persistence, connection-pooling, and configuration. Basic Usage:: >>> import requests >>> s = requests.Session() >>> s.get('http://httpbin.org/get') Or as a context manager:: >>> with requests.Session() as s: >>> s.get('http://httpbin.org/get') R:RbtauthRGthookstparamsRERFtprefetchtadaptersRCRwRScCst|_d|_i|_t|_i|_t|_ t |_ d|_ t |_t |_ti|_t|_|jdt|jdtdS(Nshttps://shttp://(RR:R#RRGRRRRQRCRRERFRRSRwRRbRRtmountR(R<((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyt__init__Xs           cCs|S(N((R<((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyt __enter__scGs|jdS(N(RT(R<targs((sB/opt/alt/python27/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 RRItfilestdatatjsonR:R)RRRbR(RbR$Rt CookieJarRR R RRwRRIR tprepareRtupperRRRR/R:RRR4R(R<RuRbtmerged_cookiesRtp((sB/opt/alt/python27/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, 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 RRIR:RRRRRRbRRDRH(R RRtmerge_environment_settingsRIR%Rg(R<RRIRRR:RbRRRDRHRGRRCRERFRRhtpreptsettingst send_kwargsR=((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyRus*)       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 RHR(R~RRu(R<RItkwargs((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyR1scKs#|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 RHtOPTIONS(R~RRu(R<RIR((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pytoptionsscKs#|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 RHR(R~RQRu(R<RIR((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pytheadscKs|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, 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(Ru(R<RIRRR((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pytpost%s cKs|jd|d||S(sYSends a PUT request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, 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(Ru(R<RIRR((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pytput1s cKs|jd|d||S(s[Sends a PATCH request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary, 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(Ru(R<RIRR((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pytpatch<s 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(Ru(R<RIR((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pytdeleteGsc 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 RCRERFRGs#You can only send PreparedRequests.RHRItsecondsR0iRi(R~RCRERFRGR$R t ValueErrorR^RR1Rt get_adapterRItpreferred_clockRgRtelapsedRRLR RbRuRORstinserttnextt_nextt StopIterationRM( R<RuRRHRCRtadaptertstarttrRR=tgenRL((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyRgQsB     %  (  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 R|tREQUESTS_CA_BUNDLEtCURL_CA_BUNDLERERGRCRFN(RwR#R1RR&R~RtostenvironR/RGRCRERF( R<RIRGRCRERFR|t env_proxiesR+R,((sB/opt/alt/python27/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&tlowerRUR(R<RItprefixR((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyRscCs(x!|jjD]}|jqWdS(s+Closes all adapters and as such the sessionN(RtvaluesRT(R<R,((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyRTscCso||j|s(tdictt __attrs__(R<tstate((R<sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyt __getstate__scCs1x*|jD]\}}t|||q WdS(N(R&tsetattr(R<RRtvalue((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyt __setstate__sN(RRt__doc__RRRRRR#RRuR1RRRRRRRgRRRTRRR(((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyR?s2  7   ) D  I    cCstS(sQ Returns a :class:`Session` for context-management. :rtype: Session (R(((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pytsessions(=RRtsysttimetdatetimeRRRtcompatRRRRRRRbRR R R tmodelsR R RRRRt_internal_utilsRtutilsRRt exceptionsRRRRt structuresRRRRRRRRRt status_codesR R!tplatformt perf_counterRtAttributeErrortclockR/R4tobjectR5RR(((sB/opt/alt/python27/lib/python2.7/site-packages/requests/sessions.pyt s:   ."".