ó â\e[c@s·dZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ej eƒZejdƒZd „Zd efd „ƒYZdS( s7 The httplib2 algorithms ported for use with requests. iÿÿÿÿN(t parsedate_tz(tCaseInsensitiveDicti(t DictCache(t Serializers9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?cCs<tj|ƒjƒ}|d|d|d|d|dfS(s‡Parses a URI using the regex given in Appendix B of RFC 3986. (scheme, authority, path, query, fragment) = parse_uri(uri) iiiii(tURItmatchtgroups(turiR((sB/tmp/pip-install-0xiv62/pip/pip/_vendor/cachecontrol/controller.pyt parse_uristCacheControllercBsteZdZd ed d d„Zed„ƒZed„ƒZd„Z d„Z d„Z d d d„Z d„Z RS( s9An interface to see if request should cached or not. cCs@|p tƒ|_||_|p'tƒ|_|p6d|_dS(NiÈiËi,i-(iÈiËi,i-(Rtcachet cache_etagsRt serializertcacheable_status_codes(tselfR R R t status_codes((sB/tmp/pip-install-0xiv62/pip/pip/_vendor/cachecontrol/controller.pyt__init__"s c Csšt|ƒ\}}}}}| s)| r<td|ƒ‚n|jƒ}|jƒ}|scd}n|r~dj||gƒp|}|d||}|S(s4Normalize the URL to create a safe key for the caches(Only absolute URIs are allowed. uri = %st/t?s://(Rt Exceptiontlowertjoin( tclsRtschemet authoritytpathtquerytfragmentt request_urit defrag_uri((sB/tmp/pip-install-0xiv62/pip/pip/_vendor/cachecontrol/controller.pyt_urlnorm*s   !cCs |j|ƒS(N(R(RR((sB/tmp/pip-install-0xiv62/pip/pip/_vendor/cachecontrol/controller.pyt cache_url>sc Csèi ttfd6ttfd6ttfd6dtfd6dtfd6dtfd6dtfd6dtfd6dtfd 6dtfd 6dtfd 6ttfd 6}|jd |jddƒƒ}i}x|jdƒD] }|jƒsîqÖn|jddƒ}|djƒ}y||\}} Wn$tk rJtj d|ƒqÖnX| sY| rfd|| %is4The cached response is "stale" with no etag, purgingN(RturlR-R.R;R2R'R R)R(R tloadstwarningtstatusRtdeletettimetcalendarttimegmRtmax(RtrequestRtcct cache_datatresptmsgR2tnowR<t current_agetresp_cctfreshness_lifetimeR>t expire_timet min_fresh((sB/tmp/pip-install-0xiv62/pip/pip/_vendor/cachecontrol/controller.pytcached_requestxsv                          cCs|j|jƒ}|jj||jj|ƒƒ}i}|r‹t|jƒ}d|krk|d|d 0R>sCaching b/c of expires header(R RBR-R.RR2R(tisdigitR%tlenR;RR?R'R&R R)RCR tsetR tdumps( RRHtresponseRWRR tresponse_headerstcc_reqRIRtno_store((sB/tmp/pip-install-0xiv62/pip/pip/_vendor/cachecontrol/controller.pytcache_response÷sX       " %   "    cs¤|j|jƒ}|jj||jj|ƒƒ}|s=|Sdg‰|jjt‡fd†|jj ƒDƒƒƒd|_ |jj ||jj ||ƒƒ|S(séOn a 304 we will get a new set of headers that we want to update our cached value with, assuming we have one. This should only ever be called when we've sent an ETag and gotten a 304 as the response. scontent-lengthc3s3|])\}}|jƒˆkr||fVqdS(N(R(t.0tktv(texcluded_headers(sB/tmp/pip-install-0xiv62/pip/pip/_vendor/cachecontrol/controller.pys cs iÈ( RR?R R@R R)R2tupdatetdicttitemsRBRZR[(RRHR\Rtcached_response((RdsB/tmp/pip-install-0xiv62/pip/pip/_vendor/cachecontrol/controller.pytupdate_cached_responseIs!    "N(R1t __module__t__doc__R(R&Rt classmethodRRR;RSRVR`Ri(((sB/tmp/pip-install-0xiv62/pip/pip/_vendor/cachecontrol/controller.pyR s 6 o R(RktloggingtreRERDt email.utilsRtpip._vendor.requests.structuresRR Rt serializeRt getLoggerR1R-tcompileRRtobjectR (((sB/tmp/pip-install-0xiv62/pip/pip/_vendor/cachecontrol/controller.pyts