
    h]                         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dS )+    )annotationsN)
getproxies   )PrimitiveDataURLvaluer   returnstrc                @    | du rdS | du rdS | dS 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falseN )r   r	   s    N/var/www/html/prod/cognitive/venv/lib/python3.11/site-packages/httpx/_utils.pyprimitive_value_to_strr      s6     }}v	%w	ru::    dict[str, str | None]c                    t                      } i }dD ]0}|                     |          r| |         }d|v r|nd| || d<   1d |                     dd                              d          D             }|D ]r}|dk    ri c S |rdd|v rd	||<   t          |          r	d	|d
| <   0t	          |          r
d	|d| d<   I|                                dk    r	d	|d
| <   jd	|d| <   s|S )z+Gets proxy information from the environment)httphttpsallz://zhttp://c                6    g | ]}|                                 S  )strip).0hosts     r   
<listcomp>z+get_environment_proxies.<locals>.<listcomp>/   s     SSStdjjllSSSr   nor   ,*Nzall://zall://[]	localhostzall://*)r   getsplitis_ipv4_hostnameis_ipv6_hostnamelower)
proxy_infomountsschemehostnameno_proxy_hostss        r   get_environment_proxiesr.      sv    J$&F*  >>&!! 	!&)H!X--3GX3G3G f>>>" TSz~~dB/G/G/M/Mc/R/RSSSN" 4 4 s??
 III 	4   #'x  !(++ 4.2***++!(++ 404,,,,--!![00.2***++/3+++,Mr   utf-8str | bytesencodingbytesc                Z    t          | t                    r|                     |          n| S N
isinstancer   encoder	   r1   s     r   to_bytesr9   O   s(    %/s%;%;F5<<!!!Fr   c                Z    t          | t                    r| n|                     |          S r4   )r6   r   decoder8   s     r   to_strr<   S   s'    uc**F55X0F0FFr   match_type_oftyping.AnyStrc                X    t          |t                    r| n|                                 S r4   r5   )r	   r=   s     r   to_bytes_or_strr@   W   s#    }c22F55Fr   c                R    | d         | d         cxk    rdk    rn n
| dd         n| S )Nr   "r   r   r   s    r   unquoterD   [   s=    (eBi666636666652;;EAr   stream
typing.Any
int | Nonec                Z   	 |                                  }t          j        |          j        }n{# t          t
          f$ rg 	 |                                 }|                     dt          j                  }|                     |           n# t          t
          f$ r Y Y dS w xY wY nw xY w|S )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)rE   fdlengthoffsets       r   peek_filelike_lengthrU   _   s    
]]__"%G$ 
 
 
	 [[]]F[[BK00FKK( 	 	 	444	  
 Ms4   -0 B(A	BB(B"B(!B""B('B(c                  R    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
dS )
URLPatterna  
    A utility class currently used for making lookups against proxy keys...

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

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

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

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

    # With port matching...
    >>> pattern = URLPattern("https://example.com:1234")
    >>> pattern.matches(httpx.URL("https://example.com:1234"))
    True
    >>> pattern.matches(httpx.URL("https://example.com"))
    False
    patternr   r
   Nonec                   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 | _        d S |j                            d
          r@t          j
        |j        dd                    }t          j        d| d          | _        d S |j                            d	          r@t          j
        |j        dd                    }t          j        d| d          | _        d S t          j
        |j                  }t          j        d| d          | _        d S )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   
ValueErrorrX   r+   r   port
host_regex
startswithreescapecompile)selfrX   r   urldomains        r   __init__zURLPattern.__init__   s    	s'))>&> >07> > >   c'llJ%//bbSZ(c//BBsx	H	x 	838s??:>DOOOX  && 	8Ysx|,,F j);&);););<<DOOOX  %% 	8Ysx|,,F j)>V)>)>)>??DOOO Ysx((F jV77DOOOr   otherr   boolc                    | j         r| j         |j         k    rdS | j        r(| j        !| j                            |j                  sdS | j        | j        |j        k    rdS dS )NFT)r+   r   rb   matchra   rg   rk   s     r   matcheszURLPattern.matches   sr    ; 	4;%,665I	+O))%*55 , 59 TY%*%<%<5tr   tuple[int, int, int]c                v    | 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.
        Nr   r   )ra   lenr   r+   )rg   port_priorityhost_priorityscheme_prioritys       r   priorityzURLPattern.priority   sB     "Y2TYt{+++}o>>r   intc                *    t          | j                  S r4   )hashrX   )rg   s    r   __hash__zURLPattern.__hash__   s    DL!!!r   c                "    | j         |j         k     S r4   )rw   ro   s     r   __lt__zURLPattern.__lt__   s    }u~--r   rF   c                L    t          |t                    o| j        |j        k    S r4   )r6   rW   rX   ro   s     r   __eq__zURLPattern.__eq__   s     %,,N1NNr   N)rX   r   r
   rY   )rk   r   r
   rl   )r
   rq   )r
   rx   )rk   rW   r
   rl   )rk   rF   r
   rl   )__name__
__module____qualname____doc__rj   rp   propertyrw   r{   r}   r   r   r   r   rW   rW   x   s        ' 'R8 8 8 8<    ? ? ? X?" " " ". . . .O O O O O Or   rW   r,   rl   c                    	 t          j        |                     d          d                    n# t          $ r Y dS w xY wdS N/r   FT)	ipaddressIPv4Addressr%   	Exceptionr,   s    r   r&   r&      S    hnnS11!45555   uu4   -0 
>>c                    	 t          j        |                     d          d                    n# t          $ r Y dS w xY wdS r   )r   IPv6Addressr%   r   r   s    r   r'   r'      r   r   )r	   r   r
   r   )r
   r   )r/   )r	   r0   r1   r   r
   r2   )r	   r0   r1   r   r
   r   )r	   r   r=   r>   r
   r>   )r	   r   r
   r   )rE   rF   r
   rG   )r,   r   r
   rl   )
__future__r   r   rJ   rd   typingurllib.requestr   _typesr   TYPE_CHECKINGr_   r   r   r.   r9   r<   r@   rD   rU   rW   r&   r'   r   r   r   <module>r      s   " " " " " "     				 				  % % % % % % ! ! ! ! ! !	    . . . .bG G G G GG G G G GG G G GB B B B   2jO jO jO jO jO jO jO jOZ        r   