Ë
    Eü´jÌ!  ã                  óÌ   — d dl mZ d dlZd dlZd dlZd dlZd dlmZ ddlm	Z	 ej                  rddlmZ dd„Zdd„Zddd	„Zddd
„Zdd„Zdd„Zdd„Z G d„ d«      Zdd„Zdd„Zy)é    )ÚannotationsN)Ú
getproxiesé   )ÚPrimitiveData©ÚURLc                ó2   — | du ry| du ry| €yt        | «      S )z‡
    Coerce a primitive data type into a string value.

    Note that we prefer JSON-style 'true'/'false' for boolean values here.
    TÚtrueFÚfalseÚ )Ústr)Úvalues    úK/root/workspace/ytshorts/venv/lib/python3.12/site-packages/httpx2/_utils.pyÚprimitive_value_to_strr      s*   € ð ��}ØØ	�%‰ØØ	ˆØÜˆu‹:Ðó    c                 ó  — t        «       } i }dD ]*  }| j                  |«      sŒ| |   }d|v r|nd|› �||› d�<   Œ, | j                  dd«      j                  d«      D �cg c]  }|j                  «       ‘Œ }}|D ]Š  }|dk(  ri c S |sŒd|v rd||<   Œt	        |«      r	d|d	|› �<   Œ-t        |«      r/d
|v r!|j                  d
«      \  }}}d|d|› d|› �<   Œ]d|d|› d�<   Œg|j                  «       dk(  r	d|d	|› �<   Œƒd|d|› �<   ŒŒ |S c c}w )z+Gets proxy information from the environment)ÚhttpÚhttpsÚallz://zhttp://Únor   ú,Ú*Nzall://ú/zall://[z]/ú]Ú	localhostzall://*)r   ÚgetÚsplitÚstripÚis_ipv4_hostnameÚis_ipv6_hostnameÚ	partitionÚlower)	Ú
proxy_infoÚmountsÚschemeÚhostnameÚhostÚno_proxy_hostsÚaddrÚ_Úsubnets	            r   Úget_environment_proxiesr,      sh  € ô “€JØ$&€Fà*ò ]ˆØ�>‰>˜&Õ!Ø! &Ñ)ˆHØ16¸(Ñ1B¡XÈ'ÐRZÐQ[ÐH\ˆF�f�X˜S�>Ò"ð]ð
 0:¯~©~¸dÀBÓ/G×/MÑ/MÈcÓ/RÖS t�d—j‘j•lÐS€NÐSØ"ò 4ˆð �sŠ?ð
 ŠIÚð ˜Ñ Ø#'��xÒ Ü! (Ô+Ø.2�˜ ˜zÐ*Ò+Ü! (Ô+Ø˜(‘?Ø&.×&8Ñ&8¸Ó&=‘O�D˜!˜VØ9=�F˜W T F¨"¨V¨HÐ5Ò6à48�F˜W X J¨aÐ0Ò1Ø—‘Ó! [Ò0Ø.2�˜ ˜zÐ*Ò+à/3�˜  
Ð+Ò,ð=4ð@ €MùòC Ts   ÁD	c                óH   — t        | t        «      r| j                  |«      S | S ©N©Ú
isinstancer   Úencode©r   Úencodings     r   Úto_bytesr4   Q   s   € Ü%/°´sÔ%;ˆ5�<‰<˜Ó!ÐFÀÐFr   c                óH   — t        | t        «      r| S | j                  |«      S r.   )r0   r   Údecoder2   s     r   Úto_strr7   U   s   € Ü˜u¤cÔ*ˆ5ÐF°·±¸XÓ0FÐFr   c                óF   — t        |t        «      r| S | j                  «       S r.   r/   )r   Úmatch_type_ofs     r   Úto_bytes_or_strr:   Y   s   € Ü˜}¬cÔ2ˆ5ÐF¸¿¹»ÐFr   c                óB  — 	 | j                  «       }t        j                  |«      j                  }|S # t        t
        f$ r\ 	 | j                  «       }| j                  dt        j                  «      }| j                  |«       Y |S # t        t
        f$ r Y Y yw xY ww xY w)zs
    Given a file-like stream object, return its length in number of bytes
    without reading it into memory.
    r   N)	ÚfilenoÚosÚfstatÚst_sizeÚAttributeErrorÚOSErrorÚtellÚseekÚSEEK_END)ÚstreamÚfdÚlengthÚoffsets       r   Úpeek_filelike_lengthrI   ]   s”   € ð
à�]‰]‹_ˆä—‘˜"“×%Ñ%ˆð €Møô œGÐ$ò 
ð	ð —[‘[“]ˆFØ—[‘[ ¤B§K¡KÓ0ˆFØ�K‰K˜Õð
 €Møô	 ¤Ð(ò 	âð	úð
ús(   ‚/3 ³BÁABÂBÂBÂBÂBc                óÎ   — 	 | j                  «       }| j                  dt        j                  «      }| j                  |«       t        d||z
  «      S # t        t
        f$ r Y yw xY w)zFReturn the remaining byte length without changing the stream position.r   N)rB   rC   r=   rD   r@   rA   Úmax)rE   rH   rG   s      r   Úpeek_filelike_remaining_lengthrL   v   s^   € ðØ—k‘k“mˆØ—k‘k !¤R§[¡[Ó1ˆØ�‰�FÔô ˆq�&˜6‘/Ó"Ð"øô œGÐ$ò Ùðús   ‚AA ÁA$Á#A$c                  óJ   — e Zd ZdZd	d„Zd
d„Zedd„«       Zdd„Zdd„Z	dd„Z
y)Ú
URLPatternaÖ  
    A utility class currently used for making lookups against proxy keys...

    # Wildcard matching...
    >>> pattern = URLPattern("all://")
    >>> pattern.matches(httpx2.URL("http://example.com"))
    True

    # Witch scheme matching...
    >>> pattern = URLPattern("https://")
    >>> pattern.matches(httpx2.URL("https://example.com"))
    True
    >>> pattern.matches(httpx2.URL("http://example.com"))
    False

    # With domain matching...
    >>> pattern = URLPattern("https://example.com")
    >>> pattern.matches(httpx2.URL("https://example.com"))
    True
    >>> pattern.matches(httpx2.URL("http://example.com"))
    False
    >>> pattern.matches(httpx2.URL("https://other.com"))
    False

    # Wildcard scheme, with domain matching...
    >>> pattern = URLPattern("all://example.com")
    >>> pattern.matches(httpx2.URL("https://example.com"))
    True
    >>> pattern.matches(httpx2.URL("http://example.com"))
    True
    >>> pattern.matches(httpx2.URL("https://other.com"))
    False

    # With port matching...
    >>> pattern = URLPattern("https://example.com:1234")
    >>> pattern.matches(httpx2.URL("https://example.com:1234"))
    True
    >>> pattern.matches(httpx2.URL("https://example.com"))
    False
    c                ó8  — ddl m} |rd|vrt        d|› d|› d�«      ‚ ||«      }|| _        |j                  dk(  rdn|j                  | _        |j
                  d	k(  rdn|j
                  | _        |j                  | _        |j
                  r|j
                  d	k(  rd | _        y |j
                  j                  d
«      rAt        j                  |j
                  dd  «      }t        j                  d|› d�«      | _        y |j
                  j                  d	«      rAt        j                  |j
                  dd  «      }t        j                  d|› d�«      | _        y t        j                  |j
                  «      }t        j                  d|› d�«      | _        y )Nr   r   ú:zUProxy keys should use proper URL forms rather than plain scheme strings. Instead of "z", use "z://"r   r   r   z*.é   z^.+\.ú$z^(.+\.)?ú^)Ú_urlsr   Ú
ValueErrorÚpatternr%   r'   ÚportÚ
host_regexÚ
startswithÚreÚescapeÚcompile)ÚselfrV   r   ÚurlÚdomains        r   Ú__init__zURLPattern.__init__¬   sI  € Ýá�s 'Ñ)Üðà&˜i x°¨y¸ð>óð ñ �'‹lˆØˆŒØŸJ™J¨%Ò/‘b°S·Z±ZˆŒØŸ(™( cš/‘B¨s¯x©xˆŒ	Ø—H‘HˆŒ	Ø�xŠx˜3Ÿ8™8 sš?Ø:>ˆD�OØ�X‰X× Ñ  Ô&ä—Y‘Y˜sŸx™x¨¨˜|Ó,ˆFÜ Ÿj™j¨6°&°¸Ð);Ó<ˆD�OØ�X‰X× Ñ  Ô%ä—Y‘Y˜sŸx™x¨¨˜|Ó,ˆFÜ Ÿj™j¨9°V°H¸AÐ)>Ó?ˆD�Oô —Y‘Y˜sŸx™xÓ(ˆFÜ Ÿj™j¨1¨V¨H°A¨Ó7ˆD�Or   c                ó  — | j                   r| j                   |j                   k7  ry| j                  r2| j                  �&| j                  j                  |j                  «      sy| j                  �| j                  |j                  k7  ryy)NFT)r%   r'   rX   ÚmatchrW   ©r]   Úothers     r   ÚmatcheszURLPattern.matchesÊ   se   € Ø�;Š;˜4Ÿ;™;¨%¯,©,Ò6ØØ�9Š9˜Ÿ™Ð4¸T¿_¹_×=RÑ=RÐSX×S]ÑS]Ô=^ØØ�9‰9Ð  T§Y¡Y°%·*±*Ò%<ØØr   c                ó„   — | j                   �dnd}t        | j                  «       }t        | j                  «       }|||fS )z�
        The priority allows URLPattern instances to be sortable, so that
        we can match from most specific to least specific.
        r   r   )rW   Úlenr'   r%   )r]   Úport_priorityÚhost_priorityÚscheme_prioritys       r   ÚpriorityzURLPattern.priorityÓ   sA   € ð "ŸY™YÐ2™¸ˆä˜TŸY™Y›˜ˆä˜tŸ{™{Ó+Ð+ˆØ˜}¨oÐ>Ð>r   c                ó,   — t        | j                  «      S r.   )ÚhashrV   )r]   s    r   Ú__hash__zURLPattern.__hash__á   s   € Ü�D—L‘LÓ!Ð!r   c                ó4   — | j                   |j                   k  S r.   )rk   rc   s     r   Ú__lt__zURLPattern.__lt__ä   s   € Ø�}‰}˜uŸ~™~Ñ-Ð-r   c                óX   — t        |t        «      xr | j                  |j                  k(  S r.   )r0   rN   rV   rc   s     r   Ú__eq__zURLPattern.__eq__ç   s!   € Ü˜%¤Ó,ÒN°·±ÀÇÁÑ1NÐNr   N)rV   r   ÚreturnÚNone)rd   r   rs   Úbool)rs   ztuple[int, int, int])rs   Úint)rd   rN   rs   ru   )rd   ú
typing.Anyrs   ru   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r`   re   Úpropertyrk   rn   rp   rr   © r   r   rN   rN   ‚   s6   „ ñ'óR8ó<ð ò?ó ð?ó"ó.ôOr   rN   c                ór   — 	 t        j                  | j                  d«      d   «       y# t        $ r Y yw xY w©Nr   r   FT)Ú	ipaddressÚIPv4Addressr   Ú	Exception©r&   s    r   r   r   ë   ó<   € ðÜ×Ñ˜hŸn™n¨SÓ1°!Ñ4Ô5ð øô ò Ùðúó   ‚'* ª	6µ6c                ór   — 	 t        j                  | j                  d«      d   «       y# t        $ r Y yw xY wr   )r€   ÚIPv6Addressr   r‚   rƒ   s    r   r    r    ó   r„   r…   )r   r   rs   r   )rs   zdict[str, str | None])zutf-8)r   ústr | bytesr3   r   rs   Úbytes)r   rˆ   r3   r   rs   r   )r   r   r9   útyping.AnyStrrs   rŠ   )rE   rw   rs   z
int | None)r&   r   rs   ru   )Ú
__future__r   r€   r=   rZ   ÚtypingÚurllib.requestr   Ú_typesr   ÚTYPE_CHECKINGrT   r   r   r,   r4   r7   r:   rI   rL   rN   r   r    r}   r   r   ú<module>r�      sf   ðÝ "ã Û 	Û 	Û Ý %å !à	×ÒÝóó0ôfGôGóGóó2	#÷fOñ fOóRôr   