o
    EhY                     @   st  d dl Z d dlZd dlmZ d dlZd dlZddl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 ddlm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" dd	l#m$Z$ dd
l%m&Z& ddl'm(Z( ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6m7Z7m8Z8m9Z9m:Z: e8e;Z<dZ=G dd dZ>G dd de>Z?G dd de>Z@G dd dZAdS )    N)TracebackType   )Auth	BasicAuthFunctionAuth)	DEFAULT_MAX_REDIRECTSDEFAULT_POOL_LIMITSDEFAULT_TIMEOUT_CONFIGUNSET
PoolLimitsProxy	SSLConfigTimeout	UnsetType)ContentStream)	HTTPError
InvalidURLRequestBodyUnavailableTooManyRedirects)URLCookiesHeadersOriginQueryParamsRequestResponse)codes)ASGITransport)WSGITransport)	AuthTypes	CertTypesCookieTypesHeaderTypesProxiesTypesQueryParamTypesRequestDataRequestFilesTimeoutTypesURLTypesVerifyTypes)	NetRCInfoget_environment_proxies
get_loggershould_not_be_proxiedwarn_deprecatedg      @c                   @   s  e Zd Zddddeeddddedededede	d	e
d
edefddZdeje dedejeef fddZedefddZejdeddfddZedefddZejdeddfddZedefddZejdeddfddZdddddddded	dedededed ej dedededed!edej!e	e"f dd"fd#d$Z#ddddddd%dedededed ej dededede$fd&d'Z%dede&fd(d)Z'	d>dedeje fd*d+Z(	d>dedeje fd,d-Z)	d>dedeje fd.d/Z*d>d0e$dede+fd1d2Z,d0e$d3e-de$fd4d5Z.d0e$d3e-defd6d7Z/d0e$d3e-de&fd8d9Z0d0e$de&dedefd:d;Z1d0e$dedeje2 fd<d=Z3dS )?
BaseClientNTauthparamsheaderscookiestimeoutmax_redirectsbase_url	trust_envr1   r2   r3   r4   r5   r6   r7   r8   c          	      C   st   |d u rt ddd| _nt || _|d u ri }|| _t|| _t|| _t|| _t	|| _
|| _|| _t | _d S )N Tallow_relative)r   r7   r1   r   _paramsr   _headersr   _cookiesr   r5   r6   r8   r*   netrc)	selfr1   r2   r3   r4   r5   r6   r7   r8    rA   H/var/www/html/env_mimamsha/lib/python3.10/site-packages/httpx/_client.py__init__5   s   




zBaseClient.__init__proxiesreturnc                 C   s   |d u r|rdd t   D S i S t|tttfr,t|ttfr&t|dn|}d|iS t|tjr6tdi }| D ]+\}}t|tttfr]t|ttfrTt|dn|}||t|< q<t|tjrgtdq<|S )Nc                 S   s   i | ]
\}}|t |d qS )url)r   ).0keyrG   rA   rA   rB   
<dictcomp>W   s    
z,BaseClient.get_proxy_map.<locals>.<dictcomp>rF   allz_Passing a transport instance to 'proxies=' is no longer supported. Use `httpx.Proxy() instead.`)	r+   items
isinstancestrr   r   httpcoreAsyncHTTPTransportRuntimeError)r@   rD   r8   proxynew_proxiesrI   valuerA   rA   rB   get_proxy_mapR   s0   zBaseClient.get_proxy_mapc                 C      | j S )z@
        HTTP headers to include when sending requests.
        )r=   r@   rA   rA   rB   r3   q      zBaseClient.headersc                 C      t || _d S N)r   r=   )r@   r3   rA   rA   rB   r3   x      c                 C   rV   )zA
        Cookie values to include when sending requests.
        )r>   rW   rA   rA   rB   r4   |   rX   zBaseClient.cookiesc                 C   rY   rZ   )r   r>   )r@   r4   rA   rA   rB   r4      r[   c                 C   rV   )zO
        Query parameters to include in the URL when sending requests.
        )r<   rW   rA   rA   rB   r2      rX   zBaseClient.paramsc                 C   rY   rZ   )r   r<   )r@   r2   rA   rA   rB   r2      r[   	datafilesjsonr2   r3   r4   r1   allow_redirectsr5   methodrG   r]   r^   r_   r`   StreamContextManagerc       	      
   C   s,   | j ||||||||d}t| ||	|
|dS )Nra   rG   r]   r^   r_   r2   r3   r4   )clientrequestr1   r`   r5   )build_requestrb   r@   ra   rG   r]   r^   r_   r2   r3   r4   r1   r`   r5   re   rA   rA   rB   stream   s"   
zBaseClient.streamr]   r^   r_   r2   r3   r4   c          	   
   C   s@   |  |}| |}| |}| |}t||||||||dS )z6
        Build and return a request instance.
        ri   )	merge_urlmerge_headersmerge_cookiesmerge_queryparamsr   )	r@   ra   rG   r]   r^   r_   r2   r3   r4   rA   rA   rB   rf      s   



zBaseClient.build_requestc                 C   sJ   | j j|d}|jdkr#t|jr#|jdkrdn|j}|jd|d}|S )z
        Merge a URL argument together with any 'base_url' on the client,
        to create the URL used for the outgoing request.
        )relative_urlhttpP   Nhttps)schemeport)r7   joinrr   hstspreloadin_hsts_preloadhostrs   	copy_with)r@   rG   rs   rA   rA   rB   rj      s
   zBaseClient.merge_urlc                 C   &   |s| j rt| j }|| |S |S )z
        Merge a cookies argument together with any cookies on the client,
        to create the cookies used for the outgoing request.
        )r4   r   update)r@   r4   merged_cookiesrA   rA   rB   rl      
   


zBaseClient.merge_cookiesc                 C   ry   )z
        Merge a headers argument together with any headers on the client,
        to create the headers used for the outgoing request.
        )r3   r   rz   )r@   r3   merged_headersrA   rA   rB   rk      r|   zBaseClient.merge_headersc                 C   ry   )z
        Merge a queryparams argument together with any queryparams on the client,
        to create the queryparams used for the outgoing request.
        )r2   r   rz   )r@   r2   merged_queryparamsrA   rA   rB   rm      r|   zBaseClient.merge_queryparamsre   c                 C   s   |d u r| j n|}|d ur0t|trt|d |d dS t|tr#|S t|r,t|dS td|jj	|jj
}}|s=|rCt||dS | jrad|jvra| j|jj}|d urat|d |d dS t S )Nr   r   )usernamepassword)funczInvalid "auth" argument.Authorization)r1   rM   tupler   r   callabler   	TypeErrorrG   r   r   r8   r3   r?   get_credentials	authority)r@   re   r1   r   r   credentialsrA   rA   rB   
build_auth  s"   


zBaseClient.build_authresponsec                 C   sN   |  ||}| ||}| |||}| ||}t| j}t|||||dS )z
        Given a request and a redirect response, return a new request that
        should be used to effect the redirect.
        )ra   rG   r3   r4   rh   )redirect_methodredirect_urlredirect_headersredirect_streamr   r4   r   )r@   re   r   ra   rG   r3   rh   r4   rA   rA   rB   build_redirect_request  s   

z!BaseClient.build_redirect_requestc                 C   sR   |j }|jtjkr|dkrd}|jtjkr|dkrd}|jtjkr'|dkr'd}|S )z
        When being redirected we may want to change the method of the request
        based on certain specs or browser behavior.
        HEADGETPOST)ra   status_coder   	SEE_OTHERFOUNDMOVED_PERMANENTLY)r@   re   r   ra   rA   rA   rB   r   (  s   zBaseClient.redirect_methodc                 C   s   |j d }t|dd}|jr|jdvrtd|j d|jr*|js*|j|jjd}|jr3|j|}|jj	rB|j	sB|j|jj	d}|S )	z<
        Return the URL for the redirect to follow.
        LocationTr:   ro   rq   zScheme "z" not supported.)rw   )fragment)
r3   r   rr   r   rw   rx   rG   is_relative_urlrt   r   )r@   re   r   locationrG   rA   rA   rB   r   ?  s   
zBaseClient.redirect_urlc                 C   sl   t |j}t|t|jkr|dd |j|d< ||jkr.|dkr.|dd |dd |dd |S )zR
        Return the headers that should be used for the redirect request.
        r   NHostr   zContent-LengthzTransfer-EncodingCookie)r   r3   r   rG   popr   ra   )r@   re   rG   ra   r3   rA   rA   rB   r   [  s   

zBaseClient.redirect_headersc                 C   s.   ||j kr|dkrdS |j std|jS )zO
        Return the body that should be used for the redirect request.
        r   NzWGot a redirect response, but the request body was streaming and is no longer available.)ra   rh   
can_replayr   )r@   re   ra   rA   rA   rB   r   s  s   
zBaseClient.redirect_streamrZ   )4__name__
__module____qualname__r	   r   r   r$   r"   r!   r'   intr(   boolrC   typingOptionalr#   DictrN   r   rU   propertyr   r3   setterr   r4   r   r2   r
   r%   r&   AnyUnionr   rh   r   rf   r   rj   rl   rk   rm   r   r   r   r   r   r   r   r   r   rA   rA   rA   rB   r/   4   s   	


	

&	




r/   c                !       d  e Zd ZdZddddddddeeedddddddedede	d	e
d
ededededededededejdejdejdef  fddZdddedddfd
ededededejdejdedejfddZdddedfded
edededededejfddZdedejfdd Zdddddddded!	d"eded#ed$e d%ej!dede	d	e
ded&edej"ee#f de$fd'd(Z%ddded)d*e&d+eded&edej"ee#f de$fd,d-Z'		dMd*e&de(de)d&ed.ej*e$ de$fd/d0Z+d*e&d.ej*e$ de(de)de$f
d1d2Z,d*e&de)de$fd3d4Z-ddddded5dedede	d	e
ded&edej"ee#f de$fd6d7Z.ddddded5dedede	d	e
ded&edej"ee#f de$fd8d9Z/ddddded5dedede	d	e
ded&edej"ee#f de$fd:d;Z0dddddddded!	ded#ed$e d%ej!dede	d	e
ded&edej"ee#f de$fd<d=Z1dddddddded!	ded#ed$e d%ej!dede	d	e
ded&edej"ee#f de$fd>d?Z2dddddddded!	ded#ed$e d%ej!dede	d	e
ded&edej"ee#f de$fd@dAZ3ddddded5dedede	d	e
ded&edej"ee#f de$fdBdCZ4dNdDdEZ5dOdFdGZ6			dPdHej7e8 dIe8dJe9ddfdKdLZ:  Z;S )QClienta  
    An HTTP client, with connection pooling, HTTP/2, redirects, cookie persistence, etc.

    Usage:

    ```python
    >>> client = httpx.Client()
    >>> response = client.get('https://example.org')
    ```

    **Parameters:**

    * **auth** - *(optional)* An authentication class to use when sending
    requests.
    * **params** - *(optional)* Query parameters to include in request URLs, as
    a string, dictionary, or list of two-tuples.
    * **headers** - *(optional)* Dictionary of HTTP headers to include when
    sending requests.
    * **cookies** - *(optional)* Dictionary of Cookie items to include when
    sending requests.
    * **verify** - *(optional)* SSL certificates (a.k.a CA bundle) used to
    verify the identity of requested hosts. Either `True` (default CA bundle),
    a path to an SSL certificate file, or `False` (disable verification).
    * **cert** - *(optional)* An SSL certificate used by the requested host
    to authenticate the client. Either a path to an SSL certificate file, or
    two-tuple of (certificate file, key file), or a three-tuple of (certificate
    file, key file, password).
    * **proxies** - *(optional)* A dictionary mapping HTTP protocols to proxy
    URLs.
    * **timeout** - *(optional)* The timeout configuration to use when sending
    requests.
    * **pool_limits** - *(optional)* The connection pool configuration to use
    when determining the maximum number of concurrently open HTTP connections.
    * **max_redirects** - *(optional)* The maximum number of redirect responses
    that should be followed.
    * **base_url** - *(optional)* A URL to use as the base when building
    request URLs.
    * **transport** - *(optional)* A transport class to use for sending requests
    over the network.
    * **dispatch** - *(optional)* A deprecated alias for transport.
    * **app** - *(optional)* An WSGI application to send requests to,
    rather than sending actual network requests.
    * **trust_env** - *(optional)* Enables or disables usage of environment
    variables for configuration.
    NTFr1   r2   r3   r4   verifycerthttp2rD   r5   pool_limitsr6   r7   	transportdispatchappr8   r1   r2   r3   r4   r   r   r   rD   r5   r   r6   r7   r   r   r   r8   c             
      s   t  j|||||	||d |}|d ur"td |d u r"|}j ||d_ fdd| D _d S )Nr0   oThe dispatch argument is deprecated since v0.13 and will be removed in a future release, please use 'transport'r   r   r   r   r   r   r8   c                    (   i | ]\}}|j | d qS )r   r   r   r   r8   init_proxy_transportrH   rI   rR   r   r   r   r@   r8   r   rA   rB   rJ         	z#Client.__init__.<locals>.<dictcomp>)superrC   rU   r.   init_transportr   rL   rD   r@   r1   r2   r3   r4   r   r   r   rD   r5   r   r6   r7   r   r   r   r8   	proxy_map	__class__r   rB   rC     s:   		zClient.__init__rE   c           	      C   F   |d ur|S |d urt |dS t|||dj}tj||j|jt|dS N)r   r   r   r8   )ssl_contextmax_keepalivemax_connectionskeepalive_expiryr   )r   r   r   rO   SyncConnectionPoolr   r   KEEPALIVE_EXPIRY	r@   r   r   r   r   r   r   r8   r   rA   rA   rB   r         

zClient.init_transportrR   c              
   C   8   t |||dj}tj|jj|jj|j||j|j	t
|dS Nr   )	proxy_urlproxy_headers
proxy_moder   r   r   r   r   )r   r   rO   SyncHTTPProxyrG   rawr3   moder   r   r   r@   rR   r   r   r   r   r8   r   rA   rA   rB   r        	zClient.init_proxy_transportrG   c                 C      | j r^t|s^|jdkr|jdkp|jdko|jdk}|j d|j }|j d| |r6|j d|j ndd| |rCd|j nd|jd	f}|D ]}|r]|| j v r]| j | }|  S qK| jS 
z
        Returns the transport instance that should be used for a given URL.
        This will either be the standard connection pool, or a proxy.
        ro   rp   rq   i  :z://Nzall://rK   rD   r-   rr   rs   rw   r   r@   rG   is_default_porthostname
proxy_keys	proxy_keyr   rA   rA   rB   transport_for_url&  $   
zClient.transport_for_urlr\   ra   r]   r^   r_   r`   c       	      
   C   s,   | j ||||||||d}| j||	|
|dS Nrc   )r1   r`   r5   rf   sendrg   rA   rA   rB   re   ?  s   
zClient.requestrh   r1   r`   r5   re   rh   c                C   st   |j jdvr
tdt|tr| jnt|}| ||}| j||||d}|s8z|	  W |
  |S |
  w |S Nr   z%URL scheme must be "http" or "https".)r1   r5   r`   )rG   rr   r   rM   r   r5   r   r   send_handling_redirectsreadcloser@   re   rh   r1   r`   r5   r   rA   rA   rB   r   \  s   	

zClient.sendhistoryc                 C   s   |d u rg }	 t || jkrt | j||||d}t||_|js$|S |r*|  | ||}||g }|sFt	j
| j|||d|d|_|S qNT)r1   r5   r   F)re   r1   r5   r`   r   )lenr6   r   send_handling_authlistr   is_redirectr   r   	functoolspartialr   	call_nextr@   re   r1   r5   r`   r   r   rA   rA   rB   r   x  s4   

zClient.send_handling_redirectsc           	   
   C   s   |j r|  ||}t|}	 | ||}|jr|  z||}W n ty0   | Y S  tyB } z|	  |d d }~ww t
||_|  |}|| qrZ   )requires_request_bodyr   	auth_flownextsend_single_requestrequires_response_bodyr   StopIterationBaseExceptionr   r   r   append	r@   re   r   r1   r5   r   r   next_requestexcrA   rA   rB   r     s,   


zClient.send_handling_authc              
   C   s   |  |j}z|j|j |jj|jj|j| d\}}}}}W n t	y6 }	 z	|	j
du r1||	_
 d}	~	ww t||d|||d}
| j|
 |
j d|
j }|
j d| }td|j d|j d| d |
S 	zL
        Sends a single request, without handling any redirections.
        )r3   rh   r5   Nascii)http_versionr3   rh   re    zHTTP Request: z ""r   rG   re   ra   encoder   r3   rh   as_dictr   _requestr   decoder4   extract_cookiesr   reason_phraser  loggerdebugr@   re   r5   r   r  r   r  r3   rh   r  r   statusresponse_linerA   rA   rB   r     sB   
"zClient.send_single_requestr2   r3   r4   r1   r`   r5   c             
   C      | j d|||||||dS Nr   r  re   r@   rG   r2   r3   r4   r1   r`   r5   rA   rA   rB   get     z
Client.getc             
   C   r  NOPTIONSr  r  r  rA   rA   rB   options  r  zClient.optionsc             
   C   r  Nr   r  r  r  rA   rA   rB   head  r  zClient.headc       	         C       | j d|||||||||	|
dS Nr   r\   r  r@   rG   r]   r^   r_   r2   r3   r4   r1   r`   r5   rA   rA   rB   post*     zClient.postc       	         C   r   NPUTr\   r  r"  rA   rA   rB   putF  r$  z
Client.putc       	         C   r   NPATCHr\   r  r"  rA   rA   rB   patchb  r$  zClient.patchc             
   C   r  NDELETEr  r  r  rA   rA   rB   delete~  r  zClient.deletec                 C   s&   | j   | j D ]}|  q
d S rZ   )r   r   rD   valuesr@   rR   rA   rA   rB   r     s   

zClient.closec                 C   s   | S rZ   rA   rW   rA   rA   rB   	__enter__  s   zClient.__enter__exc_type	exc_value	tracebackc                 C   s   |    d S rZ   )r   r@   r1  r2  r3  rA   rA   rB   __exit__  s   zClient.__exit__TNrE   N)rE   r   NNN)<r   r   r   __doc__r	   r   r   r   r$   r"   r!   r)   r    r   r#   r'   r   r   r(   rO   SyncHTTPTransportr   CallablerC   r   r   r   r   r   r
   rN   r%   r&   r   r   r   r   re   r   r   r   r   Listr   r   r   r  r  r  r#  r'  r*  r-  r   r0  Typer   r   r5  __classcell__rA   rA   r   rB   r     s   1	
@	

	

!
!
'
0	

	

	

	

 	

 	

 	



r   c                !       r   )QAsyncClienta  
    An asynchronous HTTP client, with connection pooling, HTTP/2, redirects,
    cookie persistence, etc.

    Usage:

    ```python
    >>> async with httpx.AsyncClient() as client:
    >>>     response = await client.get('https://example.org')
    ```

    **Parameters:**

    * **auth** - *(optional)* An authentication class to use when sending
    requests.
    * **params** - *(optional)* Query parameters to include in request URLs, as
    a string, dictionary, or list of two-tuples.
    * **headers** - *(optional)* Dictionary of HTTP headers to include when
    sending requests.
    * **cookies** - *(optional)* Dictionary of Cookie items to include when
    sending requests.
    * **verify** - *(optional)* SSL certificates (a.k.a CA bundle) used to
    verify the identity of requested hosts. Either `True` (default CA bundle),
    a path to an SSL certificate file, or `False` (disable verification).
    * **cert** - *(optional)* An SSL certificate used by the requested host
    to authenticate the client. Either a path to an SSL certificate file, or
    two-tuple of (certificate file, key file), or a three-tuple of (certificate
    file, key file, password).
    * **http2** - *(optional)* A boolean indicating if HTTP/2 support should be
    enabled. Defaults to `False`.
    * **proxies** - *(optional)* A dictionary mapping HTTP protocols to proxy
    URLs.
    * **timeout** - *(optional)* The timeout configuration to use when sending
    requests.
    * **pool_limits** - *(optional)* The connection pool configuration to use
    when determining the maximum number of concurrently open HTTP connections.
    * **max_redirects** - *(optional)* The maximum number of redirect responses
    that should be followed.
    * **base_url** - *(optional)* A URL to use as the base when building
    request URLs.
    * **transport** - *(optional)* A transport class to use for sending requests
    over the network.
    * **dispatch** - *(optional)* A deprecated alias for transport.
    * **app** - *(optional)* An ASGI application to send requests to,
    rather than sending actual network requests.
    * **trust_env** - *(optional)* Enables or disables usage of environment
    variables for configuration.
    NTFr   r1   r2   r3   r4   r   r   r   rD   r5   r   r6   r7   r   r   r   r8   c             
      s   t  j|||||	||d |d urtd |d u r|}|}j ||d_ fdd| D _d S )Nr0   r   r   c                    r   r   r   r   r   rA   rB   rJ   	  r   z(AsyncClient.__init__.<locals>.<dictcomp>)r   rC   r.   rU   r   r   rL   rD   r   r   r   rB   rC     s:   		zAsyncClient.__init__rE   c           	      C   r   r   )r   r   r   rO   AsyncConnectionPoolr   r   r   r   rA   rA   rB   r     r   zAsyncClient.init_transportrR   c              
   C   r   r   )r   r   rO   AsyncHTTPProxyrG   r   r3   r   r   r   r   r   rA   rA   rB   r   1  r   z AsyncClient.init_proxy_transportrG   c                 C   r   r   r   r   rA   rA   rB   r   I  r   zAsyncClient.transport_for_urlr\   ra   r]   r^   r_   r`   c       	      
      s8   | j ||||||||d}| j||	|
|dI d H }|S r   r   )r@   ra   rG   r]   r^   r_   r2   r3   r4   r1   r`   r5   re   r   rA   rA   rB   re   b  s   
zAsyncClient.requestr   re   rh   c                   s   |j jdvrtdt|tr| jnt|}| ||}| j||||dI d H }|sEz|	 I d H  W |
 I d H  |S |
 I d H  w |S r   )rG   rr   r   rM   r   r5   r   r   r   areadacloser   rA   rA   rB   r     s   	zAsyncClient.sendr   c                    s   |d u rg }	 t || jkrt | j||||dI d H }t||_|js(|S |r1| I d H  | ||}||g }|sMt	j
| j|||d|d|_|S qr   )r   r6   r   r   r   r   r   rB  r   r   r   r   r   r   rA   rA   rB   r     s6   

z#AsyncClient.send_handling_redirectsc           	   
      s   |j r| I d H  ||}t|}	 | ||I d H }|jr(| I d H  z||}W n  ty:   | Y S  tyO } z
|	 I d H  |d d }~ww t
||_| I d H  |}|| qrZ   )r   rB  r   r   r   r   r   r   r   rC  r   r   r   r   rA   rA   rB   r     s.   


zAsyncClient.send_handling_authc              
      s   |  |j}z|j|j |jj|jj|j| dI dH \}}}}}W n t	y: }	 z	|	j
du r5||	_
 d}	~	ww t||d|||d}
| j|
 |
j d|
j }|
j d| }td|j d|j d| d |
S r  r  r  rA   rA   rB   r     sD   

"zAsyncClient.send_single_requestr  c             
      "   | j d|||||||dI d H S r  r  r  rA   rA   rB   r       zAsyncClient.getc             
      rD  r  r  r  rA   rA   rB   r  $  rE  zAsyncClient.optionsc             
      rD  r  r  r  rA   rA   rB   r  :  rE  zAsyncClient.headc       	            (   | j d|||||||||	|
dI d H S r!  r  r"  rA   rA   rB   r#  P     zAsyncClient.postc       	            rF  r%  r  r"  rA   rA   rB   r'  l  rG  zAsyncClient.putc       	            rF  r(  r  r"  rA   rA   rB   r*    rG  zAsyncClient.patchc             
      rD  r+  r  r  rA   rA   rB   r-    rE  zAsyncClient.deletec                    s4   | j  I d H  | j D ]	}| I d H  qd S rZ   )r   rC  rD   r.  r/  rA   rA   rB   rC    s
   zAsyncClient.aclosec                    s   | S rZ   rA   rW   rA   rA   rB   
__aenter__  s   zAsyncClient.__aenter__r1  r2  r3  c                    s   |   I d H  d S rZ   )rC  r4  rA   rA   rB   	__aexit__  s   zAsyncClient.__aexit__r6  r7  )rE   r?  r8  )<r   r   r   r9  r	   r   r   r   r$   r"   r!   r)   r    r   r#   r'   r   r   r(   rO   rP   r   r;  rC   r   r   r   r   r   r
   rN   r%   r&   r   r   r   r   re   r   r   r   r   r<  r   r   r   r  r  r  r#  r'  r*  r-  rC  rH  r=  r   r   rI  r>  rA   rA   r   rB   r?    s   4	
@	

	

"
!
'

2	

	

	

	

 	

 	

 	



r?  c                   @   s   e Zd Zddedddedededed	ej	e
ef d
eddfddZdddZ			ddeje dededdfddZdddZ			ddeje dededdfddZdS )rb   NTF)r1   r`   r5   close_clientrd   re   r1   r`   r5   rJ  rE   c                C   s(   || _ || _|| _|| _|| _|| _d S rZ   )rd   re   r1   r`   r5   rJ  )r@   rd   re   r1   r`   r5   rJ  rA   rA   rB   rC     s   

zStreamContextManager.__init__r   c                 C   s6   t | jtsJ | jj| j| j| j| jdd| _| jS NT)re   r1   r`   r5   rh   )	rM   rd   r   r   re   r1   r`   r5   r   rW   rA   rA   rB   r0    s   zStreamContextManager.__enter__r1  r2  r3  c                 C   s2   t | jtsJ | j  | jr| j  d S d S rZ   )rM   rd   r   r   r   rJ  r4  rA   rA   rB   r5    s
   
zStreamContextManager.__exit__c                    s>   t | jts	J | jj| j| j| j| jddI d H | _| jS rK  )	rM   rd   r?  r   re   r1   r`   r5   r   rW   rA   rA   rB   rH    s   zStreamContextManager.__aenter__c                    s@   t | jts	J | j I d H  | jr| j I d H  d S d S rZ   )rM   rd   r?  r   rC  rJ  r4  rA   rA   rB   rI    s   zStreamContextManager.__aexit__)rE   r   r8  )r   r   r   r
   r/   r   r   r   r   r   r'   r   rC   r0  r=  r   r   r5  rH  rI  rA   rA   rA   rB   rb     s\    	



rb   )Br   r   typesr   ru   rO   _authr   r   r   _configr   r   r	   r
   r   r   r   r   r   _content_streamsr   _exceptionsr   r   r   r   _modelsr   r   r   r   r   r   r   _status_codesr   _transports.asgir   _transports.wsgir   _typesr   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   _utilsr*   r+   r,   r-   r.   r   r  r   r/   r   r?  rb   rA   rA   rA   rB   <module>   s>    ,$4  S    $    *