o
    Z�¿j-  ã                
   @   sj  d dl mZmZmZmZmZmZmZmZ d dl	m
Z
mZmZmZmZ edeeee f eeee f eeeef  eeeef  eeeef  f Zddeeef dedefdd	„Zd
dhZdeeeee f  deeeee f  fdd„Z	ddeeef dedee defdd„Z	ddeeeedf dee deedf fdd„ZG dd„ deeee f ƒZdS )é    )Ú	ItemsViewÚIterableÚIteratorÚKeysViewÚMappingÚMutableMappingÚSequenceÚ
ValuesView)ÚAnyÚAnyStrÚOptionalÚUnionÚcastÚHeadersúutf-8ÚvalueÚencodingÚreturnc                 C   s   t | tƒr| S |  |¡S ©N)Ú
isinstanceÚstrÚdecode©r   r   © r   úU/home/dinkstrade/pdmp/venv/lib/python3.10/site-packages/curl_cffi/requests/headers.pyÚto_str   ó   r   Úauthorizationzproxy-authorizationÚitemsc                 c   s@   � | D ]\}}t | ¡ ƒtv rt|tƒrdnd}||fV  qd S )Ns   [secure]z[secure])r   ÚlowerÚSENSITIVE_HEADERSr   Úbytes)r   ÚkÚvr   r   r   Úobfuscate_sensitive_headers#   s   €ýr$   Nr   c                 C   s,   t | tƒr| n|  |pd¡}|r| ¡ S |S )zE
    Coerce str/bytes into a strictly byte-wise HTTP header key.
    Úascii)r   r!   Úencoder   )r   r   r   Úbytes_valuer   r   r   Únormalize_header_key,   s   	ÿr(   c                 C   sD   | du rdS t | tƒr| S t | tƒrt| ƒ ¡ S tt| ƒ |p d¡S )zG
    Coerce str/bytes into a strictly byte-wise HTTP header value.
    Nzlatin-1)r   r!   Úintr   r&   r   r   r   r   r   Únormalize_header_value;   s   

r*   c                	   @   sÈ  e Zd ZdZ	d3dee dee fdd„Zedefdd	„ƒZ	e	j
d
eddfdd	„ƒZ	edeeeee f  fdd„ƒZdee fdd„Zdeee  fdd„Zdeeee f fdd„Zdeeeee f  fdd„Zd4dededefdd„Zd5dededeee  fdd„Zd4dee ddfdd„Zd6d d!„Zdedee fd"d#„Zded
ee ddfd$d%„Zdeddfd&d'„Zdedefd(d)„Zde e fd*d+„Z!de"fd,d-„Z#d.edefd/d0„Z$defd1d2„Z%dS )7r   z9
    HTTP headers, as a case-insensitive multi-dict.
    NÚheadersr   c                    sì   |  t |tƒrt|jƒ| _ˆ p|j‰ n^|sg | _nXt |tƒr+‡ fdd„| ¡ D ƒ| _nFt |tƒrqt |d ttB ƒr^t |d tƒrBdnd}g }|D ]}|j	|dd�\}}| 
|| ¡ f¡ qHn	t |d tƒrg|}‡ fdd„|D ƒ| _ˆ | _d S )	Nc                    ó4   g | ]\}}t |d ˆ d�t |dˆ d�t|ˆ ƒf‘qS ©F)r   r   T©r(   r*   ©Ú.0r"   r#   ©r   r   r   Ú
<listcomp>_   ó    üýÿz$Headers.__init__.<locals>.<listcomp>r   ú:ó   :é   )Úmaxsplitc                    r,   r-   r.   r/   r1   r   r   r2   r   r3   )r   r   ÚlistÚ_listr   r   r   r   r!   ÚsplitÚappendÚstripÚtupleÚ	_encoding)Úselfr+   r   ÚsepÚhÚliner"   r#   r   r1   r   Ú__init__T   s0   



ú
þ
ú
	zHeaders.__init__r   c              
   C   sv   | j du r8dD ]-}| jD ] \}}z| |¡ |dur| |¡n| W q ty,   Y  nw || _  | j S qd| _ | j S )zn
        Header encoding is mandated as ascii, but we allow fallbacks to utf-8
        or iso-8859-1.
        N)r%   r   z
iso-8859-1)r>   Úrawr   ÚUnicodeDecodeError)r?   r   Úkeyr   r   r   r   r   }   s    

€ÿö	zHeaders.encodingr   c                 C   s
   || _ d S r   )r>   )r?   r   r   r   r   r   –   s   
c                 C   s   dd„ | j D ƒS )zH
        Returns a list of the raw header items, as byte pairs.
        c                 S   s   g | ]	\}}}||f‘qS r   r   )r0   Úraw_keyÚ_r   r   r   r   r2   Ÿ   ó    zHeaders.raw.<locals>.<listcomp>©r9   ©r?   r   r   r   rD   š   s   zHeaders.rawc                    s   ‡ fdd„ˆ j D ƒ ¡ S )Nc                    s    i | ]\}}}|  ˆ j¡d “qS r   ©r   r   ©r0   rH   rF   rK   r   r   Ú
<dictcomp>¢   s     z Headers.keys.<locals>.<dictcomp>)r9   ÚkeysrK   r   rK   r   rO   ¡   r   zHeaders.keysc                 C   sj   i }| j D ]+\}}}| | j¡}|d ur| | j¡nd}||v r,||  d|› �7  < q|||< q| ¡ S )NÚNoneú, )r9   r   r   Úvalues©r?   Úvalues_dictrH   rF   r   Ústr_keyÚ	str_valuer   r   r   rR   ¤   s   
zHeaders.valuesc                 C   sj   i }| j D ]+\}}}| | j¡}|dur| | j¡nd}||v r,||  d|› �7  < q|||< q| ¡ S )z›
        Return `(key, value)` items of headers. Concatenate headers
        into a single comma separated value when a key occurs multiple times.
        NrP   rQ   )r9   r   r   r   rS   r   r   r   r   ¯   s   
zHeaders.itemsc                    s   ‡ fdd„ˆ j D ƒS )z¹
        Return a list of `(key, value)` pairs of headers. Allow multiple
        occurrences of the same key without concatenating into a single
        comma separated value.
        c                    s6   g | ]\}}}|  ˆ j¡|d ur|  ˆ j¡n|f‘qS r   rL   )r0   rF   rH   r   rK   r   r   r2   Ä   s    
ýþÿz'Headers.multi_items.<locals>.<listcomp>rJ   rK   r   rK   r   Úmulti_items¾   s   
ûzHeaders.multi_itemsrF   Údefaultc                 C   s"   z| | W S  t y   | Y S w )zˆ
        Return a header value. If multiple occurrences of the header occur
        then concatenate them together with commas.
        )ÚKeyError)r?   rF   rX   r   r   r   ÚgetÌ   s
   
ÿzHeaders.getFÚsplit_commasc                    sZ   |  ¡  ˆj¡‰ ‡ ‡fdd„ˆjD ƒ}|s|S g }|D ]}| dd„ | d¡D ƒ¡ q|S )zÆ
        Return a list of all header values for a given key.
        If `split_commas=True` is passed, then any comma separated header
        values are split into multiple return strings.
        c                    s6   g | ]\}}}|  ¡ ˆ kr|d ur| ˆj¡n|‘qS r   )r   r   r   )r0   rH   Úitem_keyÚ
item_value©Úget_header_keyr?   r   r   r2   Þ   s
    þz$Headers.get_list.<locals>.<listcomp>c                 S   s   g | ]}|  ¡ ‘qS r   )r<   ©r0   Úitemr   r   r   r2   é   ó    ú,)r   r&   r   r9   Úextendr:   )r?   rF   r[   rR   Úsplit_valuesr   r   r^   r   Úget_listÖ   s   þzHeaders.get_listc                 C   s6   t |ƒ}|D ]}|| v r|  |¡ q| j |j¡ d S r   )r   Úpopr9   rd   )r?   r+   rF   r   r   r   Úupdateì   s   
€zHeaders.updatec                 C   s   t | | jd�S )Nr1   )r   r   rK   r   r   r   Úcopyó   s   zHeaders.copyc                    sT   |  ¡  ˆj¡‰ ‡ ‡fdd„ˆjD ƒ}|dgkrdS |r&d dd„ |D ƒ¡S t|ƒ‚)zÍ
        Return a single header value.
        If there are multiple headers with the same key, then we concatenate
        them with commas. See: https://tools.ietf.org/html/rfc7230#section-3.2.2
        c                    s2   g | ]\}}}|ˆ kr|d ur|  ˆj¡n|‘qS r   rL   )r0   rH   Ú
header_keyÚheader_value©Únormalized_keyr?   r   r   r2   þ   s    üÿz'Headers.__getitem__.<locals>.<listcomp>NrQ   c                 S   s   g | ]}t |ƒ‘qS r   )r   r`   r   r   r   r2     rb   )r   r&   r   r9   ÚjoinrY   )r?   rF   r   r   rl   r   Ú__getitem__ö   s   ú

zHeaders.__getitem__c                    s    |  | jpd¡}|dur|  | jpd¡n|}| ¡ ‰ ‡ fdd„t| jƒD ƒ}t|dd… ƒD ]}| j|= q.|rE|d }|ˆ |f| j|< dS | j |ˆ |f¡ dS )zs
        Set the header `key` to `value`, removing any duplicate entries.
        Retains insertion order.
        r   Nc                    s"   g | ]\}\}}}|ˆ kr|‘qS r   r   ©r0   ÚidxrH   r\   ©Ú
lookup_keyr   r   r2     s
    þz'Headers.__setitem__.<locals>.<listcomp>r6   r   )r&   r>   r   Ú	enumerater9   Úreversedr;   )r?   rF   r   Úset_keyÚ	set_valueÚfound_indexesrq   r   rr   r   Ú__setitem__  s   ÿ
þ
zHeaders.__setitem__c                    sN   |  ¡  | j¡‰ ‡ fdd„t| jƒD ƒ}|st|ƒ‚t|ƒD ]}| j|= qdS )z*
        Remove the header `key`.
        c                    s&   g | ]\}\}}}|  ¡ ˆ kr|‘qS r   )r   rp   ©Údel_keyr   r   r2   0  s
    þz'Headers.__delitem__.<locals>.<listcomp>N)r   r&   r   rt   r9   rY   ru   )r?   rF   Úpop_indexesrq   r   rz   r   Ú__delitem__*  s   
þ
ÿzHeaders.__delitem__c                 C   s$   |  ¡  | j¡}|dd„ | jD ƒv S )Nc                 S   s   g | ]\}}}|‘qS r   r   rM   r   r   r   r2   >  s    z(Headers.__contains__.<locals>.<listcomp>)r   r&   r   r9   )r?   rF   rj   r   r   r   Ú__contains__<  s   zHeaders.__contains__c                 C   s   t |  ¡ ƒS r   )ÚiterrO   rK   r   r   r   Ú__iter__@  s   zHeaders.__iter__c                 C   s
   t | jƒS r   )Úlenr9   rK   r   r   r   Ú__len__C  s   
zHeaders.__len__Úotherc                 C   sR   zt |ƒ}W n
 ty   Y dS w dd„ | jD ƒ}dd„ |jD ƒ}t|ƒt|ƒkS )NFc                 S   ó   g | ]	\}}}||f‘qS r   r   ©r0   rH   rF   r   r   r   r   r2   L  rI   z"Headers.__eq__.<locals>.<listcomp>c                 S   r„   r   r   r…   r   r   r   r2   M  rI   )r   Ú
ValueErrorr9   Úsorted)r?   rƒ   Úother_headersÚ	self_listÚ
other_listr   r   r   Ú__eq__F  s   ÿzHeaders.__eq__c                 C   sv   | j j}d}| jdkrd| j›�}tt|  ¡ ƒƒ}t|ƒ}t|ƒt|ƒk}|r1|› d|›|› d�S |› d|›|› d�S )NÚ r%   z, encoding=ú(ú))Ú	__class__Ú__name__r   r8   r$   rW   Údictr�   )r?   Ú
class_nameÚencoding_strÚas_listÚas_dictÚno_duplicate_keysr   r   r   Ú__repr__P  s   
zHeaders.__repr__)NNr   )F)r   r   )&r�   Ú
__module__Ú__qualname__Ú__doc__r   ÚHeaderTypesr   rC   Úpropertyr   Úsetterr8   r=   r!   rD   r   rO   r	   rR   r   r   rW   r
   rZ   Úboolrf   rh   ri   ro   ry   r}   r~   r   r€   r)   r‚   r‹   r—   r   r   r   r   r   O   s<    ÿÿ
ÿ)  


)r   r   )Úcollections.abcr   r   r   r   r   r   r   r	   Útypingr
   r   r   r   r   r   r!   r=   r›   r   r    r$   rž   r(   r)   r*   r   r   r   r   r   Ú<module>   sJ   (
ûÿ 
ÿ
þý
ÿþý
üÿÿÿ

þ 