U .e@s\ddlZddlZddlZddlmZddlmZddlmZddl m Z GdddeZ dS) N) HTTPAdapter)CacheController) DictCache)CallbackFileWrappercsNeZdZddhZdfdd Zdfdd Zdfd d Zfd d ZZS)CacheControlAdapterZPUTZDELETENTc sLtt|j|||pt|_||_|p*d|_|p4t} | |j||d|_dS)N)ZGET) cache_etags serializer) superr__init__rcache heuristiccacheable_methodsr controller) selfr rZcontroller_classr r rargskwZcontroller_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||ddS|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) rmethodrZcached_requestzliberrorbuild_responseZheadersupdateZconditional_headersr rsend)rrequestrr cacheablecached_responseresprrrr$s   zCacheControlAdapter.sendFc s|p|j}|s|j|kr|jr*|j|}|jdkrh|j||}||k rNd}|jdd||}n\|jdkr|j ||nBt |j t |jj |||_ |jr|jfdd}t|||_tt|||}|j|jkr|jr|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|jdS)Nr)Z chunk_left_fpZ_closerZsuper_update_chunk_lengthrr_update_chunk_lengthns z@CacheControlAdapter.build_response.._update_chunk_length)rrr ZapplyZstatusrZupdate_cached_responsereadZ release_connZcache_responserr" functoolspartialZchunkedr%types MethodTyper rrinvalidating_methodsok cache_urlZurlr deleter) rrZresponserrrr r%r!r-rr$rr9sJ       z"CacheControlAdapter.build_responsecs|jtt|dS)N)r closer rr#rrrr/s zCacheControlAdapter.close)NTNNNN)N)FN) __name__ __module__ __qualname__r+r rrr/ __classcell__rrrrr sJr) r)r'rZpip._vendor.requests.adaptersrrrr rZ filewrapperrrrrrrs