U ÀÒ.eÿã@s\ddlZddlZddlZddlmZddlmZddlmZddl m Z Gdd„deƒZ dS) éN)Ú HTTPAdapteré)ÚCacheController)Ú DictCache)ÚCallbackFileWrappercsNeZdZddhZd‡fdd„ Zd‡fdd„ Zd‡fd d „ Z‡fd d „Z‡ZS)ÚCacheControlAdapterZPUTZDELETENTc sLtt|ƒj||Ž|ptƒ|_||_|p*d|_|p4t} | |j||d�|_dS)N)ZGET)Ú cache_etagsÚ serializer) ÚsuperrÚ__init__rÚcacheÚ heuristicÚcacheable_methodsrÚ controller) Úselfr rZcontroller_classr r rÚargsÚkwZcontroller_factory©Ú __class__©úD/usr/lib/python3.8/site-packages/pip/_vendor/cachecontrol/adapter.pyr s   ÿzCacheControlAdapter.__init__c s€|p|j}|j|krhz|j |¡}Wntjk r>d}YnX|rT|j||dd�S|j |j  |¡¡t t |ƒj |f|Ž}|S)z” Send a request. Use the request information to see if it exists in the cache and cache the response if we need to and can. NT)Ú from_cache) rÚmethodrZcached_requestÚzlibÚerrorÚbuild_responseZheadersÚupdateZconditional_headersr rÚsend)rÚrequestrrÚ cacheableÚcached_responseÚresprrrr$s   zCacheControlAdapter.sendFc s|p|j}|sÄ|j|krÄ|jr*|j |¡}|jdkrh|j ||¡}||k rNd}|jdd�| ¡|}n\|jdkr‚|j  ||¡nBt |j t   |jj ||¡ƒ|_ |jrÄ|j‰‡fdd„}t ||¡|_tt|ƒ ||¡}|j|jk�r|j�r|j |j¡} |j | ¡||_|S)z¥ Build a response by making a request or using the cache. This will end up calling send and returning a potentially cached response i0TF)Zdecode_contenti-csˆƒ|jdkr|j ¡dS)Nr)Z chunk_leftÚ_fpZ_close©r©Zsuper_update_chunk_lengthrrÚ_update_chunk_lengthns z@CacheControlAdapter.build_response.._update_chunk_length)rrr ZapplyZstatusrZupdate_cached_responseÚreadZ release_connZcache_responserr"Ú functoolsÚpartialZchunkedr%ÚtypesÚ MethodTyper rrÚinvalidating_methodsÚokÚ cache_urlZurlr Údeleter) rrZresponserrrr r%r!r-rr$rr9sJ   ÿ  ÿþ ÿ z"CacheControlAdapter.build_responsecs|j ¡tt|ƒ ¡dS)N)r Úcloser rr#rrrr/ƒs zCacheControlAdapter.close)NTNNNN)N)FN) Ú__name__Ú __module__Ú __qualname__r+r rrr/Ú __classcell__rrrrr sùÿJr) r)r'rZpip._vendor.requests.adaptersrrrr rZ filewrapperrrrrrrÚs