
    Mh6                    v   U d Z ddlmZ ddlZddlZddlmZ ej        rddlZddl	Z	ddl
mZmZmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZm Z  dd	l!m"Z"m#Z#m$Z$m%Z% dd
l&m'Z' ddl(m)Z)m*Z*  ej+        dd          Z, ej+        dd          Z-ej.        ej/        e0e0e0f         ej/        e0e0ej.        e1e2f         f         ej/        e0e0de0f         f         Z3ddgZ4i a5de6d<   ddZ7ej8        dd            Z9 G d de%          Z: G d de*          Z; G d de"          Z< G d de)          Z=dS ) a  
Custom transports, with nicely configured defaults.

The following additional keyword arguments are currently supported by httpcore...

* uds: str
* local_address: str
* retries: int

Example usages...

# Disable HTTP/2 on a single specific domain.
mounts = {
    "all://": httpx.HTTPTransport(http2=True),
    "all://*example.org": httpx.HTTPTransport()
}

# Using advanced httpcore configuration, with connection retries.
transport = httpx.HTTPTransport(retries=1)
client = httpx.Client(transport=transport)

# Using advanced httpcore configuration, with unix domain sockets.
transport = httpx.HTTPTransport(uds="socket.uds")
client = httpx.Client(transport=transport)
    )annotationsN)TracebackType   )DEFAULT_LIMITSLimitsProxycreate_ssl_context)ConnectErrorConnectTimeoutLocalProtocolErrorNetworkErrorPoolTimeoutProtocolError
ProxyError	ReadErrorReadTimeoutRemoteProtocolErrorTimeoutExceptionUnsupportedProtocol
WriteErrorWriteTimeout)RequestResponse)AsyncByteStream	CertTypes
ProxyTypesSyncByteStream)URL   )AsyncBaseTransportBaseTransportTHTTPTransport)boundAAsyncHTTPTransport,dict[type[Exception], type[httpx.HTTPError]]HTTPCORE_EXC_MAPreturnc                 ^   dd l } | j        t          | j        t          | j        t          | j        t          | j        t
          | j        t          | j        t          | j        t          | j	        t          | j
        t          | j        t          | j        t          | j        t          | j        t          iS Nr   )httpcorer   r   r   r   r   r   r
   r   r   r   r   r   r   r   )r,   s    Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/httpx/_transports/default.py_load_httpcore_exceptionsr.   J   s    OOO 	!#3k|k||IZZ$&9#%7$&9     typing.Iterator[None]c               #  L  K   t          t                    dk    rt                      a	 d V  d S # t          $ ri} d }t                                          D ]*\  }}t          | |          s|t          ||          r|}+| t          |           } ||          | d } ~ ww xY wr+   )lenr(   r.   	Exceptionitems
isinstance
issubclassstr)exc
mapped_excfrom_excto_excmessages        r-   map_httpcore_exceptionsr=   _   s       !!466+ + + +
 0 6 6 8 8 	$ 	$Hfc8,,  !Z
%C%C!#
c((j!!s*!+s   0 
B#A$BB#c                  &    e Zd Zd
dZddZddZd	S )ResponseStreamhttpcore_streamtyping.Iterable[bytes]r)   Nonec                    || _         d S N_httpcore_streamselfr@   s     r-   __init__zResponseStream.__init__z        /r/   typing.Iterator[bytes]c              #  v   K   t                      5  | j        D ]}|V  	 d d d            d S # 1 swxY w Y   d S rD   r=   rF   rH   parts     r-   __iter__zResponseStream.__iter__}   s      $&& 	 	-  



	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   .22c                f    t          | j        d          r| j                                         d S d S )Nclose)hasattrrF   rR   rH   s    r-   rR   zResponseStream.close   s<    4('22 	*!'')))))	* 	*r/   N)r@   rA   r)   rB   )r)   rK   r)   rB   )__name__
__module____qualname__rI   rP   rR    r/   r-   r?   r?   y   sP        0 0 0 0   
* * * * * *r/   r?   c                  V    e Zd Zdddddedddddfd*dZd+dZ	 	 	 d,d-d$Zd.d(Zd/d)ZdS )0r#   TNFr   verifyssl.SSLContext | str | boolcertCertTypes | None	trust_envboolhttp1http2limitsr   proxyProxyTypes | Noneuds
str | Nonelocal_addressretriesintsocket_options%typing.Iterable[SOCKET_OPTION] | Noner)   rB   c                   dd l }t          |t          t          f          rt	          |          n|}t          |||          }|5|                    ||j        |j        |j	        ||||	|
|
  
        | _
        d S |j        j        dv r|                    |                    |j        j        |j        j        |j        j        |j        j                  |j        |j        j        ||j        |j        |j        |j	        |||          | _
        d S |j        j        dv r	 dd l}n# t.          $ r t/          d	          d w xY w|                    |                    |j        j        |j        j        |j        j        |j        j                  |j        ||j        |j        |j	        ||
          | _
        d S t3          d|j        j        d          )Nr   urlr[   r]   r_   
ssl_contextmax_connectionsmax_keepalive_connectionskeepalive_expiryra   rb   rf   rh   ri   rk   httphttpsschemehostporttarget)	proxy_url
proxy_authproxy_headersrr   proxy_ssl_contextrs   rt   ru   ra   rb   rk   socks5socks5h{Using SOCKS proxy, but the 'socksio' package is not installed. Make sure to install httpx using `pip install httpx[socks]`.r~   r   rr   rs   rt   ru   ra   rb   zOProxy protocol must be either 'http', 'https', 'socks5', or 'socks5h', but got .)r,   r5   r7   r   r   r	   ConnectionPoolrs   rt   ru   _poolro   rz   	HTTPProxy
raw_schemeraw_hostr|   raw_pathraw_authheadersrawrr   socksioImportError
SOCKSProxy
ValueErrorrH   r[   r]   r_   ra   rb   rc   rd   rf   rh   ri   rk   r,   rr   r   s                  r-   rI   zHTTPTransport.__init__   s4    	$.usCj$A$AL%    u(TYWWW=!00' & 6*0*J!'!8+- 1  DJJJ Y!222!++",, 9/+ 9-	 '   !>#m/'"'"3 & 6*0*J!'!8-! ,  DJJJ$ Y!666   !S   ",,",, 9/+ 9-	 '   !>' & 6*0*J!'!8 -  DJJJ  2!I,2 2 2     "D' 'ErH   r"   c                8    | j                                          | S rD   )r   	__enter__rT   s    r-   r   zHTTPTransport.__enter__   s    
r/   exc_typetype[BaseException] | None	exc_valueBaseException | None	tracebackTracebackType | Nonec                    t                      5  | j                            |||           d d d            d S # 1 swxY w Y   d S rD   )r=   r   __exit__rH   r   r   r   s       r-   r   zHTTPTransport.__exit__   s     %&& 	@ 	@J)Y???	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s   9= =requestr   r   c           	     P   t          |j        t                    sJ dd l}|                    |j        |                    |j        j        |j        j	        |j        j
        |j        j                  |j        j        |j        |j                  }t                      5  | j                            |          }d d d            n# 1 swxY w Y   t          |j        t$          j                  sJ t)          |j        |j        t-          |j                  |j                  S Nr   ry   )methodro   r   content
extensions)status_coder   streamr   )r5   r   r   r,   r   r   r   ro   r   r   r|   r   r   r   r   r=   r   handle_requesttypingIterabler   statusr?   rH   r   r,   reqresps        r-   r   zHTTPTransport.handle_request   sV    '..99999>{-[)[%{+	    O'N)  
 
 %&& 	2 	2:,,S11D	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 $+v77777L!$+..	
 
 
 	
s   !CCCc                8    | j                                          d S rD   )r   rR   rT   s    r-   rR   zHTTPTransport.close  s    
r/   r[   r\   r]   r^   r_   r`   ra   r`   rb   r`   rc   r   rd   re   rf   rg   rh   rg   ri   rj   rk   rl   r)   rB   )rH   r"   r)   r"   NNNr   r   r   r   r   r   r)   rB   r   r   r)   r   rU   )	rV   rW   rX   r   rI   r   r   r   rR   rY   r/   r-   r#   r#      s         /3!%'#'$(@DO O O O Ob    04*.*.	@ @ @ @ @
 
 
 
>     r/   c                  &    e Zd Zd
dZddZddZd	S )AsyncResponseStreamr@   typing.AsyncIterable[bytes]r)   rB   c                    || _         d S rD   rE   rG   s     r-   rI   zAsyncResponseStream.__init__
  rJ   r/   typing.AsyncIterator[bytes]c                  K   t                      5  | j        2 3 d {V }|W V  6 	 d d d            d S # 1 swxY w Y   d S rD   rM   rN   s     r-   	__aiter__zAsyncResponseStream.__aiter__  s      $&& 	 	"3       d




 43	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   5&599c                v   K   t          | j        d          r!| j                                         d {V  d S d S )Naclose)rS   rF   r   rT   s    r-   r   zAsyncResponseStream.aclose  sR      4((33 	1'..00000000000	1 	1r/   N)r@   r   r)   rB   )r)   r   rU   )rV   rW   rX   rI   r   r   rY   r/   r-   r   r   	  sP        0 0 0 0   
1 1 1 1 1 1r/   r   c                  V    e Zd Zdddddedddddfd*dZd+dZ	 	 	 d,d-d$Zd.d(Zd/d)ZdS )0r&   TNFr   r[   r\   r]   r^   r_   r`   ra   rb   rc   r   rd   re   rf   rg   rh   ri   rj   rk   rl   r)   rB   c                   dd l }t          |t          t          f          rt	          |          n|}t          |||          }|5|                    ||j        |j        |j	        ||||	|
|
  
        | _
        d S |j        j        dv r|                    |                    |j        j        |j        j        |j        j        |j        j                  |j        |j        j        |j        ||j        |j        |j	        |||          | _
        d S |j        j        dv r	 dd l}n# t.          $ r t/          d	          d w xY w|                    |                    |j        j        |j        j        |j        j        |j        j                  |j        ||j        |j        |j	        ||
          | _
        d S t3          d          )Nr   rn   rp   rq   rv   ry   )r~   r   r   r   rr   rs   rt   ru   ra   rb   rk   r   r   r   zdProxy protocol must be either 'http', 'https', 'socks5', or 'socks5h', but got {proxy.url.scheme!r}.)r,   r5   r7   r   r   r	   AsyncConnectionPoolrs   rt   ru   r   ro   rz   AsyncHTTPProxyr   r   r|   r   r   r   r   rr   r   r   AsyncSOCKSProxyr   r   s                  r-   rI   zAsyncHTTPTransport.__init__  s    	$.usCj$A$AL%    u(TYWWW=!55' & 6*0*J!'!8+- 6  DJJJ Y!222!00",, 9/+ 9-	 '   !>#m/"'"3' & 6*0*J!'!8-! 1  DJJJ$ Y!666   !S   "11",, 9/+ 9-	 '   !>' & 6*0*J!'!8 2  DJJJ  1  r   rH   r%   c                H   K   | j                                          d {V  | S rD   )r   
__aenter__rT   s    r-   r   zAsyncHTTPTransport.__aenter__i  s1      j##%%%%%%%%%r/   r   r   r   r   r   r   c                   K   t                      5  | j                            |||           d {V  d d d            d S # 1 swxY w Y   d S rD   )r=   r   	__aexit__r   s       r-   r   zAsyncHTTPTransport.__aexit__m  s       %&& 	G 	G*&&xIFFFFFFFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs   #AAAr   r   r   c           	     `  K   t          |j        t                    sJ dd l}|                    |j        |                    |j        j        |j        j	        |j        j
        |j        j                  |j        j        |j        |j                  }t                      5  | j                            |           d {V }d d d            n# 1 swxY w Y   t          |j        t$          j                  sJ t)          |j        |j        t-          |j                  |j                  S r   )r5   r   r   r,   r   r   r   ro   r   r   r|   r   r   r   r   r=   r   handle_async_requestr   AsyncIterabler   r   r   r   s        r-   r   z'AsyncHTTPTransport.handle_async_requestv  sm      './:::::>{-[)[%{+	    O'N)  
 
 %&& 	> 	>88========D	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> $+v';<<<<<L&t{33	
 
 
 	
s   #!CCCc                H   K   | j                                          d {V  d S rD   )r   r   rT   s    r-   r   zAsyncHTTPTransport.aclose  s2      j!!!!!!!!!!!r/   r   )rH   r%   r)   r%   r   r   r   rU   )	rV   rW   rX   r   rI   r   r   r   r   rY   r/   r-   r&   r&     s         /3!%'#'$(@DO O O O Ob    04*.*.	G G G G G
 
 
 
>" " " " " "r/   )r)   r'   )r)   r0   )>__doc__
__future__r   
contextlibr   typesr   TYPE_CHECKINGsslhttpx_configr   r   r   r	   _exceptionsr
   r   r   r   r   r   r   r   r   r   r   r   r   r   _modelsr   r   _typesr   r   r   r   _urlsr   baser    r!   TypeVarr"   r%   UnionTuplerj   bytes	bytearraySOCKET_OPTION__all__r(   __annotations__r.   contextmanagerr=   r?   r#   r   r&   rY   r/   r-   <module>r      s2    4 # " " " " "           	 JJJLLL G G G G G G G G G G G G                                 ( ' ' ' ' ' ' ' K K K K K K K K K K K K       3 3 3 3 3 3 3 3FN3o...FN32333
Lc3
Lc6<y(899:
Lc4$%'  
1AC  C C C C   * + + + +2* * * * *^ * * *    M   D1 1 1 1 1/ 1 1 1" " " " "+ " " " " "r/   