U ʗRe @ @ s d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m Z mZ ddlm Z eeZedZd Zd d ZG dd d eZdS )z7 The httplib2 algorithms ported for use with requests. N)parsedate_tz)CaseInsensitiveDict ) DictCacheSeparateBodyBaseCache) Serializerz9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)- 4 c C s0 t | }|d |d |d |d |d fS )zParses a URI using the regex given in Appendix B of RFC 3986. (scheme, authority, path, query, fragment) = parse_uri(uri) r )URImatchgroups)urir r /builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/cachecontrol/controller.py parse_uri s r c @ sf e Zd ZdZdddZedd Zedd Zd d Zdd Z dd Z dddZdddZdd Z dS )CacheControllerz4An interface to see if request should cached or not.NTc C s4 |d krt n|| _|| _|p"t | _|p,d| _d S )N) i, r r )r cachecache_etagsr serializercacheable_status_codes)selfr r r status_codesr r r __init__' s zCacheController.__init__c C sh t |\}}}}}|r|s&td| | }| }|s>d}|rPd||gpR|}|d | | }|S )z4Normalize the URL to create a safe key for the cachez(Only absolute URIs are allowed. uri = %s/?z://)r Exceptionlowerjoin) clsr scheme authoritypathqueryfragmentrequest_uri defrag_urir r r _urlnorm/ s zCacheController._urlnormc C s | |S N)r, )r$ r r r r cache_urlC s zCacheController.cache_urlc C s( t dft dft dfddddddddt dfd}|d|dd}i }|dD ]}| s^qP|d d }|d }z|| \}} W n$ tk r td| Y qPY nX |r| sd ||<