o
    ûÞh�C  ã                   @  s4  d dl mZ d dlZd dlmZ d dlmZmZ d dlm	Z	 ej
r5d dlmZ d dlmZ G dd	„ d	eƒZd
dgZe d¡Ze d¡Ze d¡Zejdejeef ejeeef  d	f ZG dd„ deƒZddd„ZG dd
„ d
ejeef ejeef ƒZG dd„ deeeef  ƒZ G dd„ dejeef ƒZ!dS )é    )ÚannotationsN)ÚOrderedDict)ÚEnumÚauto)ÚRLock)ÚProtocol)ÚSelfc                   @  s    e Zd Zd
dd„Zddd„Zd	S )ÚHasGettableStringKeysÚreturnútyping.Iterator[str]c                 C  ó   d S ©N© ©Úselfr   r   úT/var/www/html/premium_crap/venv/lib/python3.10/site-packages/urllib3/_collections.pyÚkeys   ó    zHasGettableStringKeys.keysÚkeyÚstrc                 C  r   r   r   ©r   r   r   r   r   Ú__getitem__   r   z!HasGettableStringKeys.__getitem__N©r
   r   ©r   r   r
   r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r	      s    
r	   ÚRecentlyUsedContainerÚHTTPHeaderDictÚ_KTÚ_VTÚ_DTc                   @  s   e Zd Zeƒ ZdS )Ú	_SentinelN)r   r   r   r   Ú
not_passedr   r   r   r   r"   '   s    
r"   Ú	potentialÚobjectr
   úValidHTTPHeaderSource | Nonec                 C  sz   t | tƒr| S t | tjƒrt tjttf | ¡S t | tjƒr+t tjtttf  | ¡S t| dƒr;t| dƒr;t d| ¡S d S )Nr   r   r	   )	Ú
isinstancer   ÚtypingÚMappingÚcastr   ÚIterableÚtupleÚhasattr)r$   r   r   r   Ú%ensure_can_construct_http_header_dict+   s   
r.   c                      s�   e Zd ZU dZded< ded< ded< ded	< 	
	d%d&‡ fdd„Zd'dd„Zd(dd„Zd)dd„Zd*dd„Z	d+dd„Z
d,d d!„Zd-d#d$„Z‡  ZS ).r   a‘  
    Provides a thread-safe dict-like container which maintains up to
    ``maxsize`` keys while throwing away the least-recently-used keys beyond
    ``maxsize``.

    :param maxsize:
        Maximum number of recent elements to retain.

    :param dispose_func:
        Every time an item is evicted from the container,
        ``dispose_func(value)`` is called.  Callback which will get called
    ztyping.OrderedDict[_KT, _VT]Ú
_containerÚintÚ_maxsizeú#typing.Callable[[_VT], None] | NoneÚdispose_funcr   Úlocké
   NÚmaxsizer
   ÚNonec                   s*   t ƒ  ¡  || _|| _tƒ | _tƒ | _d S r   )ÚsuperÚ__init__r1   r3   r   r/   r   r4   )r   r6   r3   ©Ú	__class__r   r   r9   R   s
   
zRecentlyUsedContainer.__init__r   r   r    c                 C  sD   | j � | j |¡}|| j|< |W  d   ƒ S 1 sw   Y  d S r   )r4   r/   Úpop)r   r   Úitemr   r   r   r   ]   s
   
$ýz!RecentlyUsedContainer.__getitem__Úvaluec              	   C  s°   d }| j �5 z|| j |¡f}|| j|< W n ty2   || j|< t| jƒ| jkr0| jjdd�}Y nw W d   ƒ n1 s=w   Y  |d urT| jrV|\}}|  |¡ d S d S d S )NF)Úlast)r4   r/   r<   ÚKeyErrorÚlenr1   Úpopitemr3   )r   r   r>   Úevicted_itemÚ_Úevicted_valuer   r   r   Ú__setitem__d   s"   
€ø€øþz!RecentlyUsedContainer.__setitem__c                 C  sJ   | j � | j |¡}W d   ƒ n1 sw   Y  | jr#|  |¡ d S d S r   )r4   r/   r<   r3   )r   r   r>   r   r   r   Ú__delitem__}   s   ÿÿz!RecentlyUsedContainer.__delitem__c                 C  s4   | j � t| jƒW  d   ƒ S 1 sw   Y  d S r   )r4   rA   r/   r   r   r   r   Ú__len__„   s   $ÿzRecentlyUsedContainer.__len__útyping.NoReturnc                 C  s   t dƒ‚)Nz7Iteration over this class is unlikely to be threadsafe.)ÚNotImplementedErrorr   r   r   r   Ú__iter__ˆ   s   ÿzRecentlyUsedContainer.__iter__c                 C  s`   | j � t| j ¡ ƒ}| j ¡  W d   ƒ n1 sw   Y  | jr,|D ]	}|  |¡ q$d S d S r   )r4   Úlistr/   ÚvaluesÚclearr3   )r   rM   r>   r   r   r   rN   �   s   ýþzRecentlyUsedContainer.clearúset[_KT]c                 C  s8   | j � t| j ¡ ƒW  d   ƒ S 1 sw   Y  d S r   )r4   Úsetr/   r   r   r   r   r   r   —   s   $ÿzRecentlyUsedContainer.keys)r5   N)r6   r0   r3   r2   r
   r7   )r   r   r
   r    )r   r   r>   r    r
   r7   )r   r   r
   r7   ©r
   r0   )r
   rI   )r
   r7   )r
   rO   )r   r   r   Ú__doc__Ú__annotations__r9   r   rF   rG   rH   rK   rN   r   Ú__classcell__r   r   r:   r   r   ?   s    
 ý






c                   @  sB   e Zd ZU dZded< ddd„Zdd
d„Zddd„Zddd„ZdS )ÚHTTPHeaderDictItemViewa�  
    HTTPHeaderDict is unusual for a Mapping[str, str] in that it has two modes of
    address.

    If we directly try to get an item with a particular name, we will get a string
    back that is the concatenated version of all the values:

    >>> d['X-Header-Name']
    'Value1, Value2, Value3'

    However, if we iterate over an HTTPHeaderDict's items, we will optionally combine
    these values based on whether combine=True was called when building up the dictionary

    >>> d = HTTPHeaderDict({"A": "1", "B": "foo"})
    >>> d.add("A", "2", combine=True)
    >>> d.add("B", "bar")
    >>> list(d.items())
    [
        ('A', '1, 2'),
        ('B', 'foo'),
        ('B', 'bar'),
    ]

    This class conforms to the interface required by the MutableMapping ABC while
    also giving us the nonstandard iteration behavior we want; items with duplicate
    keys, ordered by time of first insertion.
    r   Ú_headersÚheadersr
   r7   c                 C  s
   || _ d S r   )rV   )r   rW   r   r   r   r9   »   ó   
zHTTPHeaderDictItemView.__init__r0   c                 C  s   t t| j ¡ ƒƒS r   )rA   rL   rV   Ú	iteritemsr   r   r   r   rH   ¾   s   zHTTPHeaderDictItemView.__len__ú typing.Iterator[tuple[str, str]]c                 C  s
   | j  ¡ S r   )rV   rY   r   r   r   r   rK   Á   rX   zHTTPHeaderDictItemView.__iter__r=   r%   Úboolc                 C  sD   t |tƒr t|ƒdkr |\}}t |tƒr t |tƒr | j ||¡S dS )Né   F)r'   r,   rA   r   rV   Ú_has_value_for_header)r   r=   Ú
passed_keyÚ
passed_valr   r   r   Ú__contains__Ä   s
   z#HTTPHeaderDictItemView.__contains__N)rW   r   r
   r7   rQ   ©r
   rZ   )r=   r%   r
   r[   )	r   r   r   rR   rS   r9   rH   rK   r`   r   r   r   r   rU   œ   s   
 


rU   c                      s`  e Zd ZU dZded< dVdW‡ fd	d
„ZdXdd„ZdYdd„ZdZdd„Zd[dd„Z	d\d]‡ fdd„Z
d^dd„Zd^d d!„Zd_d#d$„Zd`d&d'„ZdZd(d)„Zd*d+œdad-d.„Zdbd1d2„Zejdcd4d5„ƒZejddd8d5„ƒZejfded:d5„Zdfd<d=„ZeZeZeZeZdgd>d?„Zdhd@dA„ZdfdBdC„ZdidEdF„ZdidGdH„Z djdJdK„Z!dkdNdO„Z"dldPdQ„Z#dmdRdS„Z$dmdTdU„Z%‡  Z&S )nr   ap  
    :param headers:
        An iterable of field-value pairs. Must not contain multiple field names
        when compared case-insensitively.

    :param kwargs:
        Additional field-value pairs to pass in to ``dict.update``.

    A ``dict`` like container for storing HTTP Headers.

    Field names are stored and compared case-insensitively in compliance with
    RFC 7230. Iteration provides the first case-sensitive key seen for each
    case-insensitive pair.

    Using ``__setitem__`` syntax overwrites fields that compare equal
    case-insensitively in order to maintain ``dict``'s api. For fields that
    compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add``
    in a loop.

    If multiple fields that are equal case-insensitively are passed to the
    constructor or ``.update``, the behavior is undefined and some will be
    lost.

    >>> headers = HTTPHeaderDict()
    >>> headers.add('Set-Cookie', 'foo=bar')
    >>> headers.add('set-cookie', 'baz=quxx')
    >>> headers['content-length'] = '7'
    >>> headers['SET-cookie']
    'foo=bar, baz=quxx'
    >>> headers['Content-Length']
    '7'
    z%typing.MutableMapping[str, list[str]]r/   NrW   r&   Úkwargsr   c                   sN   t ƒ  ¡  i | _|d urt|tƒr|  |¡ n|  |¡ |r%|  |¡ d S d S r   )r8   r9   r/   r'   r   Ú
_copy_fromÚextend)r   rW   rb   r:   r   r   r9   ð   s   


ÿzHTTPHeaderDict.__init__r   Úvalr
   r7   c                 C  s*   t |tƒr
| d¡}||g| j| ¡ < d S )Núlatin-1)r'   ÚbytesÚdecoder/   Úlower©r   r   re   r   r   r   rF   û   s   

zHTTPHeaderDict.__setitem__c                 C  s    | j | ¡  }d |dd … ¡S )Nú, é   ©r/   ri   Újoinrj   r   r   r   r     s   zHTTPHeaderDict.__getitem__c                 C  s   | j | ¡ = d S r   ©r/   ri   r   r   r   r   rG     s   zHTTPHeaderDict.__delitem__r%   r[   c                 C  s   t |tƒr| ¡ | jv S dS )NF)r'   r   ri   r/   r   r   r   r   r`     s   
zHTTPHeaderDict.__contains__Ú Údefaultc                   s   t ƒ  ||¡S r   )r8   Ú
setdefault©r   r   rq   r:   r   r   rr     s   zHTTPHeaderDict.setdefaultÚotherc                 C  sD   t |ƒ}|d u r
dS t| ƒ|ƒ}dd„ |  ¡ D ƒdd„ | ¡ D ƒkS )NFc                 S  s   i | ]	\}}|  ¡ |“qS r   )ri   )Ú.0ÚkÚvr   r   r   Ú
<dictcomp>  s    z)HTTPHeaderDict.__eq__.<locals>.<dictcomp>)r.   ÚtypeÚ
itermerged)r   rt   Úmaybe_constructableÚother_as_http_header_dictr   r   r   Ú__eq__  s   ÿzHTTPHeaderDict.__eq__c                 C  s   |   |¡ S r   )r}   )r   rt   r   r   r   Ú__ne__  s   zHTTPHeaderDict.__ne__r0   c                 C  s
   t | jƒS r   )rA   r/   r   r   r   r   rH     rX   zHTTPHeaderDict.__len__r   c                 c  s    � | j  ¡ D ]}|d V  qd S )Nr   )r/   rM   )r   Úvalsr   r   r   rK   !  s   €ÿzHTTPHeaderDict.__iter__c                 C  s"   z| |= W d S  t y   Y d S w r   )r@   r   r   r   r   Údiscard&  s
   ÿzHTTPHeaderDict.discardF)Úcombiner�   c                C  sx   t |tƒr
| d¡}| ¡ }||g}| j ||¡}||ur:t|ƒdks%J ‚|r3|d d | |d< dS | |¡ dS dS )aù  Adds a (name, value) pair, doesn't overwrite the value if it already
        exists.

        If this is called with combine=True, instead of adding a new header value
        as a distinct item during iteration, this will instead append the value to
        any existing header value with a comma. If no existing header value exists
        for the key, then the value will simply be added, ignoring the combine parameter.

        >>> headers = HTTPHeaderDict(foo='bar')
        >>> headers.add('Foo', 'baz')
        >>> headers['foo']
        'bar, baz'
        >>> list(headers.items())
        [('foo', 'bar'), ('foo', 'baz')]
        >>> headers.add('foo', 'quz', combine=True)
        >>> list(headers.items())
        [('foo', 'bar, baz, quz')]
        rf   r\   éÿÿÿÿrk   N)r'   rg   rh   ri   r/   rr   rA   Úappend)r   r   re   r�   Ú	key_lowerÚnew_valsr   r   r   r   Úadd,  s   

ùzHTTPHeaderDict.addÚargsÚValidHTTPHeaderSourcec                 O  s$  t |ƒdkrtdt |ƒ› d�ƒ‚t |ƒdkr|d nd}t|tƒr1| ¡ D ]
\}}|  ||¡ q%nPt|tjƒrG| ¡ D ]
\}}|  ||¡ q;n:t|tj	ƒrht 
tj	tttf  |¡}|D ]
\}}|  ||¡ q\nt|dƒr�t|dƒr�| ¡ D ]
}|  ||| ¡ qv| ¡ D ]
\}}|  ||¡ q…dS )	zÀGeneric import function for any type of header-like object.
        Adapted version of MutableMapping.update in order to insert items
        with self.add instead of self.__setitem__
        rl   z/extend() takes at most 1 positional arguments (z given)r   r   r   r   N)rA   Ú	TypeErrorr'   r   rY   r†   r(   r)   Úitemsr+   r*   r,   r   r-   r   )r   r‡   rb   rt   r   re   r>   r   r   r   rd   O  s0   ÿ
ÿÿÿÿzHTTPHeaderDict.extendú	list[str]c                 C  r   r   r   r   r   r   r   Úgetlistp  ó   zHTTPHeaderDict.getlistr!   úlist[str] | _DTc                 C  r   r   r   rs   r   r   r   rŒ   s  r�   ú_Sentinel | _DTc                 C  sH   z	| j | ¡  }W n ty   |tju rg  Y S | Y S w |dd… S )zmReturns a list of all the values for the named field. Returns an
        empty list if the key doesn't exist.rl   N)r/   ri   r@   r"   r#   )r   r   rq   r   r   r   r   rŒ   v  s   
û	r   c                 C  s    g d¢}|D ]}|   |¡ q| S )z–
        Remove content-specific header fields before changing the request
        method to GET or HEAD according to RFC 9110, Section 15.4.
        )zContent-EncodingzContent-LanguagezContent-LocationzContent-TypezContent-LengthÚDigestzLast-Modified)r€   )r   Úcontent_specific_headersÚheaderr   r   r   Ú_prepare_for_method_changeˆ  s   	z)HTTPHeaderDict._prepare_for_method_changec                 C  s   t | ƒj› dt|  ¡ ƒ› d�S )Nú(ú))ry   r   Údictrz   r   r   r   r   Ú__repr__¢  s   zHTTPHeaderDict.__repr__c                 C  s,   |D ]}|  |¡}|g|¢| j| ¡ < qd S r   )rŒ   r/   ri   )r   rt   r   re   r   r   r   rc   ¥  s   
þzHTTPHeaderDict._copy_fromc                 C  s   t | ƒƒ }| | ¡ |S r   )ry   rc   )r   Úcloner   r   r   Úcopyª  s   

zHTTPHeaderDict.copyrZ   c                 c  s>   � | D ]}| j | ¡  }|dd… D ]	}|d |fV  qqdS )z8Iterate over all header lines, including duplicate ones.rl   Nr   ro   )r   r   r   re   r   r   r   rY   ¯  s   €ÿþzHTTPHeaderDict.iteritemsc                 c  s:   � | D ]}| j | ¡  }|d d |dd… ¡fV  qdS )z:Iterate over all headers, merging duplicate ones together.r   rk   rl   Nrm   rj   r   r   r   rz   ¶  s
   €þzHTTPHeaderDict.itermergedrU   c                 C  s   t | ƒS r   )rU   r   r   r   r   rŠ   ¼  s   zHTTPHeaderDict.itemsÚheader_nameÚpotential_valuec                 C  s&   || v r|| j | ¡  dd … v S dS )Nrl   Fro   )r   rš   r›   r   r   r   r]   ¿  s   z$HTTPHeaderDict._has_value_for_headerc                 C  s"   t |ƒ}|d u r
tS |  |¡ | S r   )r.   ÚNotImplementedrd   )r   rt   r{   r   r   r   Ú__ior__Ä  s
   
zHTTPHeaderDict.__ior__c                 C  s*   t |ƒ}|d u r
tS |  ¡ }| |¡ |S r   )r.   rœ   r™   rd   ©r   rt   r{   Úresultr   r   r   Ú__or__Í  s   
zHTTPHeaderDict.__or__c                 C  s.   t |ƒ}|d u r
tS t| ƒ|ƒ}| | ¡ |S r   )r.   rœ   ry   rd   rž   r   r   r   Ú__ror__×  s   
zHTTPHeaderDict.__ror__r   )rW   r&   rb   r   )r   r   re   r   r
   r7   r   )r   r   r
   r7   )r   r%   r
   r[   )rp   )r   r   rq   r   r
   r   )rt   r%   r
   r[   rQ   r   )r   r   re   r   r�   r[   r
   r7   )r‡   rˆ   rb   r   r
   r7   )r   r   r
   r‹   )r   r   rq   r!   r
   rŽ   )r   r   rq   r�   r
   rŽ   )r
   r   )r
   r   )rt   r   r
   r7   ra   )r
   rU   )rš   r   r›   r   r
   r[   )rt   r%   r
   r   )rt   r%   r
   r   )'r   r   r   rR   rS   r9   rF   r   rG   r`   rr   r}   r~   rH   rK   r€   r†   rd   r(   ÚoverloadrŒ   r"   r#   r“   Ú
getheadersÚgetallmatchingheadersÚigetÚget_allr—   rc   r™   rY   rz   rŠ   r]   r�   r    r¡   rT   r   r   r:   r   r   Ì   sJ   
 !









#!ÿ









	
)r$   r%   r
   r&   )"Ú
__future__r   r(   Úcollectionsr   Úenumr   r   Ú	threadingr   ÚTYPE_CHECKINGr   Útyping_extensionsr   r	   Ú__all__ÚTypeVarr   r    r!   ÚUnionr)   r   r+   r,   rˆ   r"   r.   ÚGenericÚMutableMappingr   rP   rU   r   r   r   r   r   Ú<module>   s2    


ýÿ
&]0