3 ”Reã@s\ddlZddlZddlZddlmZddlmZddlmZddl m Z Gdd„deƒZ dS) éN)Ú HTTPAdapteré)ÚCacheController)Ú DictCache)ÚCallbackFileWrappercsNeZdZddhZd‡fdd„ Zd‡fdd„ Zd‡fd d „ Z‡fd d „Z‡ZS)ÚCacheControlAdapterÚPUTÚDELETENTc sTtt|ƒj||Ž|dkr tƒn||_||_|p2d|_|pd}YnX|rT|j||dd�S|jj|jj |ƒƒ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ÚmethodrÚcached_requestÚzlibÚerrorÚbuild_responseÚheadersÚupdateÚconditional_headersr rÚsend)rÚrequestrrÚ cacheableÚcached_responseÚresp)rrrr$$s   zCacheControlAdapter.sendFc s|p|j}| rÆ|j|krÆ|jr,|jj|ƒ}|jdkrj|jj||ƒ}||k rPd}|jdd�|jƒ|}n\|jdkr„|jj ||ƒnBt |j t j |jj ||ƒƒ|_ |jrÆ|j‰‡fdd„}tj||ƒ|_tt|ƒj||ƒ}|j|jkoè|j�r|jj|jƒ} |jj| ƒ||_|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)Údecode_contenti-csˆƒ|jdkr|jjƒdS)Nr)Ú chunk_leftÚ_fpÚ_close)r)Úsuper_update_chunk_lengthrrÚ_update_chunk_lengthns z@CacheControlAdapter.build_response.._update_chunk_length)rrrÚapplyÚstatusrÚupdate_cached_responseÚreadÚ release_connÚcache_responserr+Ú functoolsÚpartialÚchunkedr.ÚtypesÚ MethodTyper rr Úinvalidating_methodsÚokÚ cache_urlÚurlrÚdeleter) rr%Úresponserrr&r'r.r(r<)r)r-rr 9s:        z"CacheControlAdapter.build_responsecs|jjƒtt|ƒjƒdS)N)rÚcloser r)r)rrrr@ƒs zCacheControlAdapter.close)NTNNNN)N)FN) Ú__name__Ú __module__Ú __qualname__r:rr$r r@Ú __classcell__rr)rrr sIr) r8r5rZpip._vendor.requests.adaptersrrrrrÚ filewrapperrrrrrrÚs