
    ei                       d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlmZmZmZ d dlmZ d dl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"m#Z#m$Z$ d d
l%m&Z& ddl'm(Z( ddl)m*Z*m+Z+m,Z,m-Z- ddl.m/Z/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5m6Z6m7Z7 ddl8m9Z9m:Z:m;Z; ddl<m=Z=m>Z> ddl?m@Z@mAZAmBZB ddlCmDZDmEZE ddl2mFZFmGZGmHZHmIZI ddlJmKZKmLZLmMZMmNZNmOZO ejP        dk    r e"deEeE          ZQn e"deE          ZQerNd dlRmSZS  G d de!d           ZT G d! d"eeQ         e!d           ZU G d# d$e!d           ZV G d% d&eVd           ZWn( G d' d(          ZX eX            ZSeYeZeZf         ZTe!ZUe!e!cZVZWed)         Z[ed*         Z\dAd/Z]dBdCd2Z^dBdDd4Z_ed5         Z`e G d6 d7                      ZadEd:Zb G d; d<eeQ                   Zc G d= d>eceQ                   Zd G d? d@eceQ                   ZedS )F    )annotationsN)AsyncGeneratorCallable	Generator)ThreadPoolExecutor)asynccontextmanagercontextmanagersuppress)	dataclass)	timedelta)BytesIO)TYPE_CHECKINGGenericLiteralOptional	TypedDictTypeVarUnioncast)urlparse   )	AsyncCurl)
CurlFollowCurlHttpVersionCurlInfoCurlOpt)Curl	CurlErrorCurlMime)CurlCffiWarning   )CookiesCookieTypes
CurlMorsel)RequestExceptionSessionClosed
code2error)HeadersHeaderTypes)BrowserTypeLiteralExtraFingerprintsExtraFpDict)
STREAM_ENDResponse)NOT_SETHttpVersionLiteral
NotSetTypeset_curl_options)AsyncWebSocketAsyncWebSocketContext	WebSocketWebSocketErrorWebSocketRetryStrategy)      R)bounddefault)r;   )Unpackc                  B    e Zd ZU ded<   ded<   ded<   ded<   ded<   dS )	ProxySpecstrallhttphttpswswssN__name__
__module____qualname____annotations__     E/usr/local/lib/python3.11/dist-packages/curl_cffi/requests/session.pyr?   r?   9   s=         			


rL   r?   F)totalc                  <   e Zd ZU ded<   ded<   ded<   ded<   d	ed
<   ded<   d	ed<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   d	ed<   d	ed<   d	ed<   ded <   ded!<   d"ed#<   ded$<   d%ed&<   d'ed(<   ded)<   d	ed*<   d+ed,<   d-ed.<   ded/<   ded0<   d1S )2BaseSessionParamsOptional[HeaderTypes]headersOptional[CookieTypes]cookiesOptional[tuple[str, str]]authOptional[ProxySpec]proxiesOptional[str]proxy
proxy_authbase_urlOptional[dict]paramsboolverify!Union[float, tuple[float, float]]timeout	trust_envUnion[bool, CurlFollow, str]allow_redirectsintmax_redirectszUnion[int, RetryStrategy]retryOptional[BrowserTypeLiteral]impersonateja3akamaiperk/Optional[Union[ExtraFingerprints, ExtraFpDict]]extra_fpdefault_headers"Union[str, Callable[[bytes], str]]default_encodingcurl_optionszOptional[list]
curl_infos4Optional[Union[CurlHttpVersion, HttpVersionLiteral]]http_versiondebug	interface%Optional[Union[str, tuple[str, str]]]certOptional[type[R]]response_classdiscard_cookiesraise_for_statusNrF   rK   rL   rM   rP   rP   @   sq        &&&&&&&&''''$$$$----22225555((((1111AAAA<<<<$$$$""""JJJJ    3333))))rL   rP   c                  F   e Zd ZU ded<   ded<   ded<   ded<   d	ed
<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   d ed!<   ded"<   ded#<   ded$<   d%ed&<   ded'<   d(ed)<   d*ed+<   d,ed-<   ded.<   d/ed0<   d1ed2<   d3ed4<   d5ed6<   d7S )8StreamRequestParams"Optional[Union[dict, list, tuple]]r^   AOptional[Union[dict[str, str], list[tuple], str, BytesIO, bytes]]dataOptional[dict | list]jsonrQ   rR   rS   rT   r]   filesrU   rV   3Optional[Union[float, tuple[float, float], object]]rb   &Optional[Union[bool, CurlFollow, str]]re   Optional[int]rg   rW   rX   rY   rZ   r[   Optional[bool]r`   refereraccept_encodingOptional[Callable]content_callbackri   rj   rk   rl   rm   rn   ro   rp   rq   rr   Union[str, Literal[False]]quoteru   rv   rx   ry   rz   rf   max_recv_speedOptional[CurlMime]	multipartr_   r}   NrF   rK   rL   rM   r   r   `   s        2222OOOO####&&&&&&&&''''DDDD????$$$$$$$$----&&&&,,,,1111AAAA''''<<<<))))JJJJ    3333%%%%rL   r   c                      e Zd ZU ded<   dS )RequestParamsr   streamNrF   rK   rL   rM   r   r      s         rL   r   c                  $    e Zd Zed             ZdS )_Unpackc                     d S NrK   )argskwargss     rM   __getitem__z_Unpack.__getitem__   s    DrL   N)rG   rH   rI   staticmethodr   rK   rL   rM   r   r      s-        		 	 
	 	 	rL   r   )eventletgevent)	GETPOSTPUTDELETEOPTIONSHEADTRACEPATCHQUERYurlr@   returnr_   c                V    t          |           }t          |j        o|j                  S )z,Check if the provided url is an absolute url)r   r_   schemehostname)r   
parsed_urls     rM   _is_absolute_urlr      s&    #J
!9j&9:::rL   qqueue.Queuec                B    	 | j         d         S # t          $ r |cY S w xY wNr   )queue
IndexErrorr   r<   s     rM   _peek_queuer      s7    wqz       asyncio.Queuec                B    	 | j         d         S # t          $ r |cY S w xY wr   )_queuer   r   s     rM   _peek_aio_queuer      s7    x{   r   linearexponentialc                  D    e Zd ZU ded<   dZded<   dZded<   dZded	<   d
S )RetryStrategyrf   count        floatdelayjitterr   RetryBackoffbackoffN)rG   rH   rI   rJ   r   r   r   rK   rL   rM   r   r      sN         JJJEF$G$$$$$$rL   r   rh   #Optional[Union[int, RetryStrategy]]c                t   | d} t          | t                    r| }n5t          | t                    rt          |           }nt          d          |j        dk     rt          d          |j        dk     rt          d          |j        dk     rt          d          |j        dvrt          d          |S )	Nr   )r   z%retry must be an int or RetryStrategyzretry.count must be >= 0zretry.delay must be >= 0zretry.jitter must be >= 0r   z/retry.backoff must be 'linear' or 'exponential')	
isinstancer   rf   	TypeErrorr   
ValueErrorr   r   r   )rh   strategys     rM   _normalize_retryr      s    }%'' A	E3		 A u---?@@@~3444~34444555888JKKKOrL   c                      e Zd ZdZddddddddddddddddddddddddddddddddLd:ZdMdBZdC ZdNdFZedOdH            Z	e	j
        dPdK            Z	dS )QBaseSessionzMProvide common methods for setting curl options and reading info in sessions.NT   r   utf-8F)rR   rT   rV   rX   rZ   r[   r\   r^   r`   rb   rc   re   rg   rh   rj   rk   rl   rm   ro   rp   rr   rs   rt   rv   rw   rx   rz   r|   r}   r~   rR   rQ   rT   rS   rV   rU   rX   rW   rZ   rY   r[   r\   r^   Optional[dict[str, object]]r`   r_   rb   ra   rc   re   rd   rg   rf   rh   r   rj   ri   rk   rl   rm   ro   rn   rp   rr   rq   rs   Optional[dict[CurlOpt, str]]rt   Optional[list[object]]rv   ru   rw   rx   rz   ry   r|   r{   r}   r~   c                  t          |          | _        t          |          | _        || _        || _        || _        |	| _        |
| _        || _	        || _
        || _        t          |          | _        || _        || _        || _        || _        || _        || _        || _        |pi | _        |pg | _        || _        || _        || _        || _        |*t7          |t8                    du rt;          d| d          |pt8          | _        || _        || _         |r|rt;          d          |rd|i}|pi | _!        || _"        | j        r#tG          | j                  stI          d          d| _%        | j        du s| j        LtL          j'        (                    d          p%tL          j'        (                    d	          p| j        | _        d S d S )
NFzZ`response_class` must be a subclass of `curl_cffi.requests.models.Response`, not of type ``z)Cannot specify both 'proxy' and 'proxies'rA   z2You need to provide an absolute url for 'base_url'TREQUESTS_CA_BUNDLECURL_CA_BUNDLE))r(   rR   r"   _cookiesrV   r\   r^   r`   rb   rc   re   rg   r   rh   rj   rk   rl   rm   ro   rp   rr   rs   rt   rv   rw   rx   rz   
issubclassr.   r   r|   r}   r~   rX   r[   r   r   _closedosenvironget)selfrR   rT   rV   rX   rZ   r[   r\   r^   r`   rb   rc   re   rg   rh   rj   rk   rl   rm   ro   rp   rr   rs   rt   rv   rw   rx   rz   r|   r}   r~   s                                  rM   __init__zBaseSession.__init__   s   D w''((	 ".*%e,,
&	 . 0(.B$*(
"	%*^X*N*NRW*W*W2 .2 2 2  
 -8. 0 	IW 	IGHHH 	%enG")-R$= 	S!1$-!@!@ 	SQRRR ;$$+"5
344 :>>"233; KKK #6"5rL   curlr   bufferr   header_bufferr   r:   c                   |}t          t          |                     |                    }t          t          |                    t
          j                                                            |_        |r|	                                |_
        t          t          |                    t
          j                            |_        t          t          |                    t
          j                            |_        d|j        cxk    odk     nc |_        |	                                                                }g }	|D ]}
|
                                s|
                    d          r/|                    |
                                          |_        g }	[|
                    d          s|
                    d          r|	dxx         |
z  cc<   |	                    |
           t/          |	          |_        t3                      |_        |j                            d          }|D ]}	 t8          j                                        }|                    |           |                                D ]q\  }}|j                             ||j!        |"                    dd	          |"                    d
d          tG          |"                    d                               r# tH          $ r Y w xY w|p| j%        }|sCd |                    t
          j&                  D             }| j'        (                    |           t          t          |                    t
          j)                                                            |_*        t          t          |                    t
          j+                            |_,        t          t          |                    t
          j-                                                            |_.        t          t          |                    t
          j/                            |_0        ||_1        te          t          tf          |                    t
          j4                                      |_5        t          t          |                    t
          j6                            |_7        t          t          |                    t
          j8                            }	 |                                |_9        n*# tt          $ r |                    d          |_9        Y nw xY wt          t          |                    t
          j;                            |_<        t          t          |                    t
          j=                            |_>        t          t          |                    t
          j?                            |_@        t          t          |                    t
          jA                            |_B        |j<        |j@        z   |_C        | jD        D ]}|                    |          |jE        |<    |S )N   i  s   HTTP/       	z
set-cookiedomain path/secure)r   r   r   c                6    g | ]}t          j        |          S rK   )r$   from_curl_format).0cs     rM   
<listcomp>z/BaseSession._parse_response.<locals>.<listcomp>^  s0       34
+A..  rL   )secondszlatin-1)Fr   r:   r|   bytesgetinfor   EFFECTIVE_URLdecoder   getvaluecontentrf   HTTP_VERSIONrv   RESPONSE_CODEstatus_codeok
splitlinesstrip
startswithget_reason_phrasereasonappendr(   rR   r"   rT   get_listrB   SimpleCookieloaditemssetvaluer   r_   	Exceptionr}   
COOKIELISTr   update_cookies_from_curl
PRIMARY_IP
primary_ipPRIMARY_PORTprimary_portLOCAL_IPlocal_ip
LOCAL_PORT
local_portrr   r   r   
TOTAL_TIMEelapsedREDIRECT_COUNTredirect_countREDIRECT_URLredirect_urlUnicodeDecodeErrorSIZE_DOWNLOAD_Tdownload_sizeSIZE_UPLOAD_Tupload_sizeHEADER_SIZEheader_sizeREQUEST_SIZErequest_sizeresponse_sizert   infos)r   r   r   r   rr   r}   r   rspheader_linesheader_listheader_lineset_cookie_headers
set_cookiecookienamemorselmorselsredirect_url_bytesinfos                      rM   _parse_responsezBaseSession._parse_response&  sJ    1d))!,,--uaii(>??@@GGII 	, //++CKQYYx/D%E%EFFsAIIh.D$E$EFF----#----$--//::<< $&' 	, 	,K$$&& %%h// 00==DDFF
 %%d++ {/E/Ee/L/L B;.{++++k** ii [11,??, 	 	J2244J'''$*LLNN  LD&KOO%zz(B77#ZZ44#FJJx$8$899 $         *AT-A 	< 89		(BU8V8V  G M227;;;eQYYx/B%C%CDDKKMMQYYx/D%E%EFFE199X->#?#?@@GGIIc199X-@#A#ABB/UAIIh>Q4R4R(S(STTT!#qyy1H'I'IJJ!%83H)I)IJJ	D188::C! 	D 	D 	D188CCC	D !aii0H&I&IJJsAIIh.D$E$EFFsAIIh.B$C$CDDQYYx/D%E%EFF-? O 	. 	.DiiooCIdOO
s%   3B9K--
K:9K:T $UUc                2    | j         rt          d          d S )Nz'Session is closed, cannot send request.)r   r&   r   s    rM   _check_session_closedz!BaseSession._check_session_closed|  s(    < 	K IJJJ	K 	KrL   attemptr   c                    | j         }|j        dk    r|j        d|dz
  z  z  }n
|j        |z  }|j        r|t	          j        d|j                  z  }|S )Nr   r   r!   r   )rh   r   r   r   randomuniform)r   r9  r   r   s       rM   _retry_delayzBaseSession._retry_delay  sa    :},,NaGaK&89EENW,E? 	:V^C999ErL   r"   c                    | j         S r   )r   r7  s    rM   rT   zBaseSession.cookies  s
    }rL   r#   Nonec                .    t          |          | _        d S r   )r"   r   )r   rT   s     rM   rT   zBaseSession.cookies  s      ((rL   )<rR   rQ   rT   rS   rV   rU   rX   rW   rZ   rY   r[   rU   r\   rY   r^   r   r`   r_   rb   ra   rc   r_   re   rd   rg   rf   rh   r   rj   ri   rk   rY   rl   rY   rm   rY   ro   rn   rp   r_   rr   rq   rs   r   rt   r   rv   ru   rw   r_   rx   rY   rz   ry   r|   r{   r}   r_   r~   r_   )r   r   r   r   r   r   rr   rq   r}   r_   r   r:   )r9  rf   r   r   )r   r"   )rT   r#   r   r?  )rG   rH   rI   __doc__r   r5  r8  r=  propertyrT   setterrK   rL   rM   r   r      s       WW
 *.)-*.'+#04"&.2578<5648! $"DH $?F59-1MQ#'6:,0 %!&AW W W W W WrT T T TlK K K       X ^) ) ) ^) ) )rL   r   c                   |    e Zd ZdZ	 	 	 djdk fdZed             Zed             Zd ZdldZ	dldZ
edmd            Z	 	 	 	 dndodZdpdZdddddddedddddddddddddddd d!ddddd"dd#f dqdZZdddddddedddddddddddddddd d!ddddd"dd#f drd_ZdsdaZdsdbZdsdcZdsddZdsdeZdsdfZdsdgZdsdhZdsdiZ xZS )tSessionzA request session, cookies and connections will be reused. This object is
    thread-safe, but it's recommended to use a separate session for each thread.NTr   Optional[Curl]threadOptional[ThreadType]use_thread_local_curlr_   r   Unpack[BaseSessionParams[R]]r   r?  c                `    t                      j        di | || _        || _        d| _        d| _        |rWt          j                    | _        |rd| _	        || j        _
        dS d| _	        t          | j                  | j        _
        dS |r|nt          | j                  | _        dS )ag  
        Parameters set in the ``__init__`` method will be overridden by the same
        parameter in request method.

        Args:
            curl: curl object to use in the session. If not provided, a new one will be
                created. Also, a fresh curl object will always be created when accessed
                from another thread.
            thread: thread engine to use for working with other thread implementations.
                choices: eventlet, gevent.
            headers: headers to use in the session.
            cookies: cookies to add in the session.
            auth: HTTP basic auth, a tuple of (username, password), only basic auth is
                supported.
            proxies: dict of proxies to use, prefer to use proxy if they are the same.
                format: ``{"http": proxy_url, "https": proxy_url}``.
            proxy: proxy to use, format: "http://proxy_url".
                Cannot be used with the above parameter.
            proxy_auth: HTTP basic auth for proxy, a tuple of (username, password).
            base_url: absolute url to use as base for relative urls.
            params: query string for the session.
            verify: whether to verify https certs.
            timeout: how many seconds to wait before giving up.
            trust_env: use http_proxy/https_proxy and other environments, default True.
            allow_redirects: whether to allow redirection. Can be a bool, a
                ``CurlFollow`` value, or the string ``"safe"``. Use
                ``CurlFollow.SAFE`` or ``"safe"`` to reject redirects to
                internal/private IP addresses (SSRF protection).
            max_redirects: max redirect counts, default 30, use -1 for unlimited.
            retry: number of retries or ``RetryStrategy`` for failed requests.
            impersonate: which browser version to impersonate in the session.
            ja3: ja3 string to impersonate in the session.
            akamai: akamai string to impersonate in the session.
            perk: perk string to impersonate in the session.
            extra_fp: extra fingerprints options, in complement to ja3 and akamai str.
            interface: which interface use.
            default_encoding: encoding for decoding response content if charset is not
                found in headers. Defaults to "utf-8". Can be set to a callable for
                automatic detection.
            cert: a tuple of (cert, key) filenames for client cert.
            response_class: A customized subtype of ``Response`` to use.
            raise_for_status: automatically raise an HTTPError for 4xx and 5xx
                status codes.

        Notes:
            This class can be used as a context manager.

        .. code-block:: python

            from curl_cffi.requests import Session

            with Session() as s:
                r = s.get("https://example.com")
        NTFrw   rK   )superr   _thread_use_thread_local_curlr   	_executor	threadinglocal_local_is_customized_curlr   r   rw   _curl)r   r   rG  rI  r   	__class__s        rM   r   zSession.__init__  s    z 	""6"""&;#  		B#/++DK :+/(#'   +0(#'dj#9#9#9   !%A4dj+A+A+ADJJJrL   c                    | j         rd| j        rt          j        dt          d           t          | j        dd           st          | j                  | j        _	        | j        j	        S | j
        S )Nz/Creating fresh curl handle in different thread.r   )
stacklevelr   rL  )rO  rT  warningswarnr    getattrrS  r   rw   r   rU  r7  s    rM   r   zSession.curl  s|    & 	' E#    
 4;55 :#'dj#9#9#9 ;##:rL   c                D    | j         t                      | _         | j         S r   )rP  r   r7  s    rM   executorzSession.executor  s    >!/11DN~rL   c                    | S r   rK   r7  s    rM   	__enter__zSession.__enter__  s    rL   c                .    |                                   d S r   closer   r   s     rM   __exit__zSession.__exit__  s    

rL   c                F    d| _         | j                                         dS )Close the session.TN)r   r   rb  r7  s    rM   rb  zSession.close   s!    	rL   method
HttpMethodr   r@   Unpack[StreamRequestParams]Generator[R, None, None]c              +     K    | j         d||d|ddi}	 |V  |                                 dS # |                                 w xY w)z6Equivalent to ``with request(..., stream=True) as r:``rg  r   r   TNrK   )requestrb  r   rg  r   r   r)  s        rM   r   zSession.stream  sb       dlI&cIIVIIDIII	IIIIIKKKKKCIIKKKKs	   2 Ar5   c                   |                                   | j                                        }| j                                         t	          |||||| j                  }t          t          dz  |                    d                    }	|	/t          | j	                  }
|

                    |	           |
|d<   n
| j	        |d<    |j        |fi | |S )a"  Connects to a websocket url.

        Note: This method is deprecated, use WebSocket instead.

        Args:
            url: the ws url to connect.
            on_message: message callback, ``def on_message(ws, str)``
            on_error: error callback, ``def on_error(ws, error)``
            on_open: open callback, ``def on_open(ws)``
            on_close: close callback, ``def on_close(ws)``

        Other parameters are the same as ``.request``

        Returns:
            a WebSocket instance to communicate with the server.
        )r   
on_messageon_erroron_openon_closerw   NrT   )r8  r   	duphandleresetr5   rw   r   r"   r   rT   updateconnect)r   r   rp  rq  rr  rs  r   r   rD   user_cookiesmerged_cookiess              rM   
ws_connectzSession.ws_connect  s    2 	""$$$y""$$	!!*
 
 
 GdNFJJy,A,ABB#$T\22N!!,/// .F9 $F9
3!!&!!!	rL   rf   c                4    | j                                         S r   )r   upkeepr7  s    rM   r|  zSession.upkeepF  s    y!!!rL   gzip, deflate, brr   r   r   Fr^   DOptional[Union[dict[str, object], list[object], tuple[object, ...]]]r   NOptional[Union[dict[str, str], list[tuple[object, ...]], str, BytesIO, bytes]]r   r   rR   rQ   rT   rS   r   r]   rV   rU   rb   r   re   r   rg   r   rX   rW   rZ   rY   r[   r`   r   r   r   r   Optional[Callable[..., object]]rj   ri   rk   rl   rm   ro   rn   rp   rr   rq   r   r   rv   +CurlHttpVersion | HttpVersionLiteral | Nonerx   rz   ry   r   r   r   r   r}   r:   c#           	        "-./012 |r3 j                                         . j                                         }#n j         .t          .fi d|d|d j        |gd j        d|d|d j        |gd j        |gd	|d
|	p j        d|
t          u r j
        n|
d| j        n|d| j        n|d j        |gd|d|p j        d j        |gd|d|d|d|p j        d|p j        d|p j        d|p j        d|p j        d| j        n|d|d|p j        d|p j        d|d| d |!d!|p j        d" j        d#t4          j        d$t8          j        \  2-/10}$|r-."/012 f	d%}% j                            |%          }&0                                   !                    .-/"          }'tE          1          }(tG          |(tH                    r@|$r|$%                                 |&&                                 .'                                 |(2|'_(        |&|'_)        |$|'_*        1|'_         j+        r|'+                                 |'S 	  j,        d&k    r$d'd l-})|)j.        /                    .j0                   ng j,        d(k    rHd'd l1}*|*2                                j3        4                    .j0                  5                                 n.0                                  !                    .-/"          }'2|'_(         j+        r|'+                                 |'.                                 S # tl          $ rg}+ !                    .-/"          }'2|'_(        to          |+j8        ts          |+                    }, |,ts          |+          |+j8        |'          |+d }+~+ww xY w# .                                 w xY w))Nrg  r   params_listr\   r   r   headers_listcookies_listr   rV   rb   re   rg   proxies_listrZ   r[   verify_listr   r   r   rj   rk   rl   rm   ro   rp   r   rv   rx   r   r   r   rz   rs   queue_classevent_classc                   	 	                                   nm# t          $ r`} 
                              }	|_                            t          t          |           | j        |                     Y d } ~ nd } ~ ww xY wt          t          j
                                                  s,t          t          j
                                                                       t                     d S # t          t          j
                                                  s,t          t          j
                                                                       t                     w xY wr   )performr   r5  rm  
put_nowaitr%   r@   coder   rQ  Eventis_setr  putr-   )er)  r   r   rr   r}   r   header_recvedr   reqr   s     rM   r  z&Session._request_once.<locals>.perform  sM   &IIKKKK  H H H..6=2BO C #&CKLL!1#a&&!&#!F!FGGGGGGGGH  	??FFHH CY_m<<@@BBBEE*%%%%%  	??FFHH CY_m<<@@BBBEE*%%%%s-    C9 
BAA=8C9 =BC9 9A4E-r   r   r   ):r   rt  ru  r2   r^   r\   rR   r   rV   r/   rb   re   rg   rX   r[   r`   rj   rk   rl   rm   ro   rp   rv   rx   rz   rs   r   QueuerQ  r  r]  submitwaitr5  r   r   r%   r  resultrb  rm  stream_taskquit_nowr~   rN  eventlet.tpooltpoolexecuter  r   get_hub
threadpoolspawnr   r   r'   r  r@   )3r   rg  r   r^   r   r   rR   rT   r   rV   rb   re   rg   rX   rZ   r[   r`   r   r   r   rj   rk   rl   rm   ro   rp   rr   r   rv   rx   rz   r   r   r   r}   _r  r  r  r)  first_elementr   r   r  errorr   r   r   r  r   r  s3   `                         `       `          @@@@@@rM   _request_oncezSession._request_onceI  s   T  		##%%A	!!AA	AAQ,B
 ,B
 ,B
6,B
 ,B
 f--	,B

 ]],B
 ,B
 ,B
 ,00,B
 -11,B
 %,B
 ",B
 %,w$6$6DLLG,B
 )8(?$$_,B
" '4&;""#,B
& ,00',B
( %),B
* "4T_+,B
, f---,B
. G/,B
0 ,O1,B
2 .-3,B
4 $7t'75,B
6 tx7,B
8 (T[9,B
: ";,B
< .=,B
@ )8(?$$_A,B
D %E,B
F &:):G,B
H  14>I,B
J 6K,B
L *>M,B
N  iO,B
P "Q,B
R **S,B
T U,B
V "W,B
>V]A}h\  F	& & & & & & & & & & & & & -..w77K    &&6=*:O C
 (NNM-)9:: $ #LLNNN""$$$			##CK)CO#CLCI$ '$$&&&J<:--))))N**195555\X--!MMMNN$$/55ai@@DDFFFFIIKKK **v}.>  "( +((***				!  8 8 8**v}.>  ""163q6622eCFFAFC00a78  				s,   *BM  <O 
OA"N==OO Or   r   r   ru   c#                   |                                   | j        }#t          |#j        dz             D ]}$	  | j        d%i d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d |d!| d"|!d#|"c S # t
          $ r= |$|#j        k    r |                     |$dz             }%|%rt          j        |%           Y w xY wd$S )&zESend the request, see ``requests.request`` for details on parameters.r!   rg  r   r^   r   r   rR   rT   r   rV   rb   re   rg   rX   rZ   r[   r`   r   r   r   rj   rk   rl   rm   ro   rp   rr   r   rv   rx   rz   r   r   r   r}   NrK   )	r8  rh   ranger   r  r%   r=  timesleep&r   rg  r   r^   r   r   rR   rT   r   rV   rb   re   rg   rX   rZ   r[   r`   r   r   r   rj   rk   rl   rm   ro   rp   rr   r   rv   rx   rz   r   r   r   r}   r   r9  r   s&                                         rM   rm  zSession.request  sm   N 	""$$$:X^a/00 +	& +	&G*&)t) # # #!6## "6# 	#
 # $G# $G#  %# # $G# %4O# #0-# $G#  %#  *z#  "6!#" $G##$ %4O%#& &6%5'#( !,)#* +#, "6-#. /#0 &X1#2 %4O3#4 &6%55#6  %7#8 ".9#: (i;#< =#> "6?#@ $2>A#B (iC#D %4OE# # # #H $ & & &hn,,))'A+66 &Ju%%%&M+	& +	&s   A0B))AC0/C0Unpack[RequestParams]c                "     | j         dd|d|S Nr   rl  rK   rm  r   r   r   s      rM   headzSession.headF  !    t|=6s==f===rL   c                "     | j         dd|d|S Nr   rl  rK   r  r  s      rM   r   zSession.getI  !    t|<5c<<V<<<rL   c                "     | j         dd|d|S Nr   rl  rK   r  r  s      rM   postzSession.postL  r  rL   c                "     | j         dd|d|S Nr   rl  rK   r  r  s      rM   r  zSession.putO  r  rL   c                "     | j         dd|d|S Nr   rl  rK   r  r  s      rM   patchzSession.patchR  !    t|>7>>v>>>rL   c                "     | j         dd|d|S Nr   rl  rK   r  r  s      rM   deletezSession.deleteU  s!    t|?8?????rL   c                "     | j         dd|d|S Nr   rl  rK   r  r  s      rM   optionszSession.optionsX  s!    t|@9#@@@@@rL   c                "     | j         dd|d|S Nr   rl  rK   r  r  s      rM   tracezSession.trace[  r  rL   c                "     | j         dd|d|S Nr   rl  rK   r  r  s      rM   queryzSession.query^  r  rL   )NNT)
r   rF  rG  rH  rI  r_   r   rJ  r   r?  r   r?  )rg  rh  r   r@   r   ri  r   rj  )NNNN)r   r@   r   r5   )r   rf   )Frg  rh  r   r@   r^   r~  r   r  r   r   rR   rQ   rT   rS   r   r]   rV   rU   rb   r   re   r   rg   r   rX   rW   rZ   rY   r[   rU   r`   r   r   rY   r   rY   r   r  rj   ri   rk   rY   rl   rY   rm   rY   ro   rn   rp   r   rr   rq   r   r   rv   r  rx   rY   rz   ry   r   r   r   rf   r   r   r}   r_   r   r:   )Drg  rh  r   r@   r^   r   r   r   r   r   rR   rQ   rT   rS   r   r]   rV   rU   rb   r   re   r   rg   r   rX   rW   rZ   rY   r[   rU   r`   r   r   rY   r   rY   r   r   rj   ri   rk   rY   rl   rY   rm   rY   ro   rn   rp   r   rr   rq   r   r   rv   ru   rx   rY   rz   ry   r   r   r   rf   r   r   r}   r_   r   r@   r   r  r   r:   )rG   rH   rI   rA  r   rB  r   r]  r_  rd  rb  r	   r   rz  r|  r/   r  rm  r  r   r  r  r  r  r  r  r  __classcell__rV  s   @rM   rE  rE    s       T T
  $'+&*	KB KB KB KB KB KB KBZ   X   X
        
    ^  1 1 1 1 1f" " " "  &*)-)- $*.GNBF'+'+#04!%!%)<<@48! $"DH*.?F,.DH#'6:!%(, %Od d d d dT 6:RV&*)-)- $*.GNBF'+'+#04!%!%)</348! $"DH*.?F,.MQ#'6:!%(, %GU& U& U& U& U&n> > > >= = = => > > >= = = =? ? ? ?@ @ @ @A A A A? ? ? ?? ? ? ? ? ? ? ?rL   rE  c            $          e Zd ZdZddddd fdZedd            Zedd            Zd ZddZ	ddZ
d ZddZddZddZedd$            Zd%ddddedddddddd&ddddddd'dddd(d)d*d)d+dd,d-d.d+d%df$ddgZdddddddedddddddd&ddddddddhd'ddddd(dd+f ddZdddddddedddddddd&ddddddddhd'ddddd(dd+f ddZddZddZddZddZddZddZddZddZddZ xZS )AsyncSessionzAAn async request session, cookies and connections will be reused.N
   )loop
async_curlmax_clientsr   asyncio.AbstractEventLoop | Noner  AsyncCurl | Noner  rf   r   rJ  r   r?  c                    t                      j        di | || _        || _        || _        |                                  dS )a  
        Parameters set in the ``__init__`` method are overridden by the same parameter
        in request method.

        Parameters:
            loop: loop to use, if not provided, the running loop will be used.
            async_curl: [AsyncCurl](/api/curl_cffi#curl_cffi.AsyncCurl) object to use.
            max_clients: maxmium curl handle to use in the session,
                this will affect the concurrency ratio.
            headers: headers to use in the session.
            cookies: cookies to add in the session.
            auth: HTTP basic auth, a tuple of (username, password), only basic auth is
                supported.
            proxies: dict of proxies to use, prefer to use ``proxy`` if they are the
                same. format: ``{"http": proxy_url, "https": proxy_url}``.
            proxy: proxy to use, format: "http://proxy_url".
                Cannot be used with the above parameter.
            proxy_auth: HTTP basic auth for proxy, a tuple of (username, password).
            base_url: absolute url to use for relative urls.
            params: query string for the session.
            verify: whether to verify https certs.
            timeout: how many seconds to wait before giving up.
            trust_env: use http_proxy/https_proxy and other environments, default True.
            allow_redirects: whether to allow redirection. Can be a bool, a
                ``CurlFollow`` value, or the string ``"safe"``. Use
                ``CurlFollow.SAFE`` or ``"safe"`` to reject redirects to
                internal/private IP addresses (SSRF protection).
            max_redirects: max redirect counts, default 30, use -1 for unlimited.
            retry: number of retries or ``RetryStrategy`` for failed requests.
            impersonate: which browser version to impersonate in the session.
            ja3: ja3 string to impersonate in the session.
            akamai: akamai string to impersonate in the session.
            perk: perk string to impersonate in the session.
            extra_fp: extra fingerprints options, in complement to ja3 and akamai str.
            default_encoding: encoding for decoding response content if charset is not
                found in headers. Defaults to "utf-8". Can be set to a callable for
                automatic detection.
            cert: a tuple of (cert, key) filenames for client cert.
            response_class: A customized subtype of ``Response`` to use.
            raise_for_status: automatically raise an HTTPError for 4xx and 5xx
                status codes.

        Notes:
            This class can be used as a context manager, and it's recommended to use via
            ``async with``.
            However, unlike aiohttp, it is not required to use ``with``.

        .. code-block:: python

            from curl_cffi.requests import AsyncSession

            # recommended.
            async with AsyncSession() as s:
                r = await s.get("https://example.com")

            s = AsyncSession()  # it also works.
        NrK   )rM  r   _loop_acurlr  	init_pool)r   r  r  r  r   rV  s        rM   r   zAsyncSession.__init__e  sO    B 	""6"""7;
(2 +rL   asyncio.AbstractEventLoopc                N    | j         t          j                    | _         | j         S )z"Returns a reference to event loop.)r  asyncioget_running_loopr7  s    rM   r  zAsyncSession.loop  s$     : 133DJzrL   r   c                R    | j         t          | j                  | _         | j         S )N)r  )r  r   r  r7  s    rM   acurlzAsyncSession.acurl  s&    ;#333DK{rL   c                    t          j        | j                  | _        	 	 | j                            d            n# t           j        $ r Y d S w xY w3r   )r  	LifoQueuer  poolr  	QueueFullr7  s    rM   r  zAsyncSession.init_pool  sd    4;4EdFV4W4W			$$T****$   	s   < AAr   c                v   K   | j                                          d {V }|t          | j                  }|S )NrL  )r  r   r   rw   r   r   s     rM   pop_curlzAsyncSession.pop_curl  sC      "&)--//111111<dj)))DrL   r   Curl | Nonec                    t          t          j                  5  | j                            |           d d d            d S # 1 swxY w Y   d S r   )r
   r  r  r  r  r  s     rM   	push_curlzAsyncSession.push_curl  s    g'(( 	' 	'I  &&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	's   AA	Ac                
   K   | S r   rK   r7  s    rM   
__aenter__zAsyncSession.__aenter__  s      rL   c                >   K   |                                   d {V  d S r   ra  rc  s     rM   	__aexit__zAsyncSession.__aexit__  s+      jjlltrL   c                   K   | j                                          d{V  d| _        	 	 | j                                        }|r|                                 n# t
          j        $ r Y dS w xY wH)rf  NT)r  rb  r   r  
get_nowaitr  
QueueEmptyr  s     rM   rb  zAsyncSession.close  s      j         	y++-- !JJLLL%   	s   /A A.-A.c                    |                                  | j        sE| j                            |           |                                 |                     |           d S |                                 d S r   )clean_handles_and_buffersr   r  remove_handleru  r  rb  r  s     rM   release_curlzAsyncSession.release_curl  sj    &&(((| 	J$$T***JJLLLNN4     JJLLLLLrL   rg  rh  r   r@   ri  AsyncGenerator[R, None, None]c                  K    | j         d||d|ddi d{V }	 |W V  |                                 d{V  dS # |                                 d{V  w xY w)z<Equivalent to ``async with request(..., stream=True) as r:``rl  r   TNrK   )rm  aclosern  s        rM   r   zAsyncSession.stream  s       !DLOCOO6OO$OOOOOOOOO	IIII**,,#**,,s	   ? ATr}  r   r          Fg{Gzt?gMbP?i  @ 	autocloser_   r^   <dict[str, object] | list[object] | tuple[object, ...] | NonerR   HeaderTypes | NonerT   CookieTypes | NonerV   tuple[str, str] | Nonerb   /float | tuple[float, float] | NotSetType | Nonere   bool | CurlFollow | str | Nonerg   
int | NonerX   ProxySpec | NonerZ   
str | Noner[   r`   bool | Noner   r   rj   BrowserTypeLiteral | Nonerk   rl   rm   ro   &ExtraFingerprints | ExtraFpDict | Nonerp   r   str | Literal[False]rv   r  rx   rz   str | tuple[str, str] | Noner   recv_queue_sizesend_queue_sizemax_send_batch_sizecoalesce_framesws_retryWebSocketRetryStrategy | Nonerecv_time_slicer   send_time_slicemax_message_sizedrain_on_errorblock_on_recv_queue_fullrs   dict[CurlOpt, str] | Noner4   c&           &         	
 !"#$% d$%#"	
  !f%d}&t           |&                      S )a  Connects to a WebSocket.

        Args:
            url: url for the requests.
            autoclose: whether to close the WebSocket after receiving a close frame.
            params: query string for the requests.
            headers: headers to send.
            cookies: cookies to use.
            auth: HTTP basic auth, a tuple of (username, password), only basic auth is
                supported.
            timeout: how many seconds to wait before giving up.
            allow_redirects: whether to allow redirection. Can be a bool, a
                ``CurlFollow`` value, or the string ``"safe"``. Use
                ``CurlFollow.SAFE`` or ``"safe"`` to reject redirects to
                internal/private IP addresses (SSRF protection).
            max_redirects: max redirect counts, default 30, use -1 for unlimited.
            proxies: dict of proxies to use, prefer to use ``proxy`` if they are the
                same. format: ``{"http": proxy_url, "https": proxy_url}``.
            proxy: proxy to use, format: "http://user@pass:proxy_url".
                Can't be used with `proxies` parameter.
            proxy_auth: HTTP basic auth for proxy, a tuple of (username, password).
            verify: whether to verify https certs.
            referer: shortcut for setting referer header.
            accept_encoding: shortcut for setting accept-encoding header.
            impersonate: which browser version to impersonate.
            ja3: ja3 string to impersonate.
            akamai: akamai string to impersonate.
            perk: perk string to impersonate.
            extra_fp: extra fingerprints options, in complement to ja3 and akamai str.
            default_headers: whether to set default browser headers.
            quote: Set characters to be quoted, i.e. percent-encoded. Default safe
                string is ``!#$%&'()*+,/:;=?@[]~``. If set to a string, the character
                will be removed from the safe string, thus quoted. If set to False, the
                url will be kept as is, without any automatic percent-encoding, you must
                encode the URL yourself.
            http_version: limiting http version, defaults to http2.
            interface: which interface to use.
            cert: a tuple of (cert, key) filenames for client cert.
            max_recv_speed: maximum receive speed, bytes per second.
            recv_queue_size: The maximum number of incoming WebSocket
                messages to buffer internally. This queue stores messages received by
                the Curl socket that are waiting to be consumed on calling ``recv()``.
            send_queue_size: The maximum number of outgoing WebSocket
                messages to buffer before applying network backpressure. When you call
                ``send()`` the message is placed in this queue and transmitted when
                the Curl socket is next available for sending.
            max_send_batch_size: The max batch size for sent frames.
            coalesce_frames: When set, multiple pending messages in the send queue
                may be merged into a single WebSocket frame for improved throughput.
                **Warning:** This breaks the one-to-one mapping of ``send()`` calls
                to frames and should only be used when the application protocol is
                designed to handle concatenated data streams. Defaults to ``False``.
            ws_retry (WebSocketRetryStrategy): Retry policy for WebSocket messages.
            recv_time_slice: The maximum duration (in seconds) to process incoming
                messages before yielding to the event loop.
                Defaults to ``0.005`` (5ms).
            send_time_slice: The maximum duration (in seconds) to process outgoing
                messages before yielding to the event loop.
                Defaults to ``0.001`` (1ms).
            max_message_size: Maximum allowed size for a complete received
                WebSocket message (default: ``4 MiB``).
            drain_on_error: If ``True``, when a connection error occurs,
            attempt to consume all the buffered received messages first,
            before raising the error. Otherwise, raise it immediately (default).
            block_on_recv_queue_full (bool, optional): If ``False``, the connection
                is failed immediately when the receive queue is full. The message that
                caused the overflow is not delivered; any messages already buffered may
                still be drained if ``drain_on_error=True``.
            curl_options: extra curl options to use.
        r   r3   c                   %K   !                                  !                                 d {V } t          d#i d| ddd%d!j        d!j        gd!j        gd!j        gd	p!j        d
$t          u r!j	        n$d!j
        nd!j        nd!j        gddp!j        d!j        &gd ddp!j        dp!j        dp!j        dp!j        d!j        nddp!j        dp!j        dd	p!j        dt.          j        dt.          j        d}|                     t6          j        d           }|                     t6          j        d!          }	 !j                            d | j                    d {V }n8# tB          $ r+ | "                                 !#                    d             w xY wtI          tK          tL          tN                   !          | "
'#!j(        "          }	 |)                                 n## tT          $ r |+                                  w xY w|S )$Nr   rg  r   r   r\   r  r  r  rV   rb   re   rg   r  rZ   r[   r  r   r   rj   rk   rl   ro   rp   r   rv   rx   r   rz   r  r  rs   r!   r   )r  r  r  r	  r
  r  r  r  r  r  r  rw   rK   ),r8  r  r2   r\   r^   rR   rT   rV   r/   rb   re   rg   rX   r[   r`   rj   rk   rl   ro   rp   rv   rx   rz   r  r  r  setoptr   TCP_NODELAYCONNECT_ONLYr  run_in_executorr  r  rb  r  r3   r   r  r.   rw   _start_io_tasksr6   	terminate)(r   r  rD   r   rl   re   rV   r  r  rz   r
  rT   rs   rp   r  ro   rR   rv   rj   rx   rk   r  r   rg   r	  r^   rX   rZ   r[   r   r  r  r   r   r  r  rb   r   r`   r  s(      rM   _connect_coroz.AsyncSession.ws_connect.<locals>._connect_corod  s     &&(((#}}......D  % % %T%u% C% 	%
 "[&11% #lG44% #lG44% &TY% )07(:(:% -<,CD((% +8*?D&&]%  #lG44!%" e#%$ &8%%& "[&11'%(  )%* !0+%, (;4+;-%. O48/%0 ,1%2 "2T]3%6 -<,CD((7%: e;%< *>T->=%> $5t~?%@  .~A%B &TYC%D $MME%F $MMG%H *\I%AL G/33A$ A
)33D$,GGGGGGGG   

t$$$
 "0\(+T22# / /$7 /! / /!1-)Aj" " "B"""$$$$!    Is   =&F$ $5GH2 2 I)r   r3   )r4   )'r   r   r  r^   rR   rT   rV   rb   re   rg   rX   rZ   r[   r`   r   r   rj   rk   rl   rm   ro   rp   r   rv   rx   rz   r   r  r  r	  r
  r  r  r  r  r  r  rs   r  s'   ``````````````````` `````````````````` rM   rz  zAsyncSession.ws_connect  s;   ^N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	 N	` %]]__555rL   r   r   r   r   r   r   rQ   rS   r   r]   rU   r   r   r   rW   rY   r   r   r   ri   rn   rr   rq   r   ru   ry   r   r   r   r}   r:   c#                   "+,-./01K                                      d {V ,t          d*i d,d|d|d j        |gd j        d|d|d j        |gd	 j        |gd
|d|	p j        d|
t          u r j        n|
d| j	        n|d| j
        n|d j        |gd|d|p j        d j        |gd|d|d|d|p j        d|p j        d|p j        d|p j        d|p j        d| j        n|d|d|p j        d|p j        d|d | d!|!d"|p j        d# j        d$t0          j        d%t0          j        \  0+-/.}#|r j                            ,          1d++,"-./0 1f
d(}$, fd)}%t1          j         |$                      }&|&                    |%           t?          t0          j        .                                            d {V   !                    ,+-"          }'tE          /          }(tG          |(tH                    r %                    ,           |(0|'_&        |&|'_'        |#|'_(        /|'_)         j*        r|'*                                 |'S 	  j                            ,          11 d {V   !                    ,+-"          }'0|'_&         j*        r|'*                                 |' %                    ,           S # tV          $ rg}) !                    ,+-"          }'0|'_&        tY          |)j-        t]          |)                    }* |*t]          |)          |)j-        |'          |)d })~)ww xY w#  %                    ,           w xY w),Nr   rg  r   r  r\   r   r   r  r  r   rV   rb   re   rg   r  rZ   r[   r  r   r   r   rj   rk   rl   rm   ro   rp   r   rv   rx   r   r   r   rz   rs   r  r  r   r?  c                   
K   	  d {V  nm# t           $ r`} 
                              }	|_                            t	          t          |           | j        |                     Y d } ~ nd } ~ ww xY wt          t          j	                  
                                s,t          t          j	                                                                       t                     d {V  d S # t          t          j	                  
                                s,t          t          j	                                                                       t                     d {V  w xY wr   )r   r5  rm  r  r%   r@   r  r   r  r  r  r  r  r-   )r  r)  r   r   rr   r}   r   r  r   r  r   tasks     rM   r  z+AsyncSession._request_once.<locals>.perform  sy     ,JJJJJJJJ  H H H..fm5E C #&CKLL!1#a&&!&#!F!FGGGGGGGGH  }==DDFF AW]M::>>@@@%%
+++++++++++  }==DDFF AW]M::>>@@@%%
++++++++++s-    C5 
A8AA3.C5 3A88C5 5A:E/c                2                                    d S r   )r  )futr   r   s    rM   cleanupz+AsyncSession._request_once.<locals>.cleanup  s    !!$'''''rL   rK   r  )/r  r2   r^   r\   rR   rT   rV   r/   rb   re   rg   rX   r[   r`   rj   rk   rl   rm   ro   rp   rv   rx   rz   rs   r  r  r  r  
add_handlecreate_taskadd_done_callbackr   r  r5  r   r   r%   r  rm  astream_taskr  r   r~   r   r'   r  r@   )2r   rg  r   r^   r   r   rR   rT   r   rV   rb   re   rg   rX   rZ   r[   r`   r   r   r   rj   rk   rl   rm   ro   rp   rr   r   rv   rx   rz   r   r   r   r}   r  r  r!  r  r)  r  r  r  r   r   r   r  r   r  r  s2   `                         `       `        @@@@@@@rM   r  zAsyncSession._request_once  s     J ]]__$$$$$$AQ ,B
 ,B
 ,B
,B
6,B
 ,B
 f--	,B

 ]],B
 ,B
 ,B
 ,00,B
 ,00,B
 %,B
 ",B
 %,w$6$6DLLG,B
 )8(?$$_,B
" '4&;""#,B
& ,00',B
( %),B
* "4T_+,B
, f---,B
. G/,B
0 ,O1,B
2 .-3,B
4 $7t'75,B
6 tx7,B
8 (T[9,B
: ";,B
< .=,B
@ )8(?$$_A,B
D %E,B
F &:):G,B
H  14>I,B
J 6K,B
L *>M,B
N  iO,B
P "Q,B
R **S,B
T  U,B
V  W,B
>V]A}hZ  A	(:((..D, , , , , , , , , , , , , , ,( ( ( ( ( ( "-ggii88K))'222w}m4499;;;;;;;;; &&fm-= C ,A..M-)9:: $!!$'''##CK*C#CLCI$ '$$&&&J(z,,T22






 **&-1A?  "( +((***!!$''''!  8 8 8**&-1A?  ""163q6622eCFFAFC00a78  !!$''''s+   <"K0 <M$ 0
M!:A"MM!!M$ $M;c#                  K   |                                   | j        }#t          |#j        dz             D ]}$	  | j        d%i d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d |d!| d"|!d#|" d${V c S # t
          $ rC |$|#j        k    r |                     |$dz             }%|%rt          j        |%           d${V  Y w xY wd$S )&zISend the request, see ``curl_cffi.requests.request`` for details on args.r!   rg  r   r^   r   r   rR   rT   r   rV   rb   re   rg   rX   rZ   r[   r`   r   r   r   rj   rk   rl   rm   ro   rp   rr   r   rv   rx   rz   r   r   r   r}   NrK   )	r8  rh   r  r   r  r%   r=  r  r  r  s&                                         rM   rm  zAsyncSession.requestL  s     N 	""$$$:X^a/00 +	/ +	/G*//T/ # # #!6## "6# 	#
 # $G# $G#  %# # $G# %4O# #0-# $G#  %#  *z#  "6!#" $G##$ %4O%#& &6%5'#( !,)#* +#, "6-#. /#0 &X1#2 %4O3#4 &6%55#6  %7#8 ".9#: (i;#< =#> "6?#@ $2>A#B (iC#D %4OE# # # # # # # # # #H $ / / /hn,,))'A+66 /!-........./M+	/ +	/s   A6B11A
C>=C>r  c                2   K    | j         dd|d| d {V S r  r  r  s      rM   r  zAsyncSession.head  7      !T\CSCCFCCCCCCCCCrL   c                2   K    | j         dd|d| d {V S r  r  r  s      rM   r   zAsyncSession.get  7      !T\BCBB6BBBBBBBBBrL   c                2   K    | j         dd|d| d {V S r  r  r  s      rM   r  zAsyncSession.post  r(  rL   c                2   K    | j         dd|d| d {V S r  r  r  s      rM   r  zAsyncSession.put  r*  rL   c                2   K    | j         dd|d| d {V S r  r  r  s      rM   r  zAsyncSession.patch  7      !T\DcDDVDDDDDDDDDrL   c                2   K    | j         dd|d| d {V S r  r  r  s      rM   r  zAsyncSession.delete  s7      !T\EsEEfEEEEEEEEErL   c                2   K    | j         dd|d| d {V S r  r  r  s      rM   r  zAsyncSession.options  s7      !T\FFFvFFFFFFFFFrL   c                2   K    | j         dd|d| d {V S r  r  r  s      rM   r  zAsyncSession.trace  r.  rL   c                2   K    | j         dd|d| d {V S r  r  r  s      rM   r  zAsyncSession.query  r.  rL   )
r  r  r  r  r  rf   r   rJ  r   r?  )r   r  )r   r   )r   r   )r   r  r   r?  r  )r   r   r   r?  )rg  rh  r   r@   r   ri  r   r  )Lr   r@   r  r_   r^   r  rR   r  rT   r  rV   r  rb   r  re   r  rg   r  rX   r   rZ   r  r[   r  r`   r  r   r  r   r  rj   r  rk   r  rl   r  rm   r  ro   r  rp   r  r   r  rv   r  rx   r  rz   r  r   rf   r  rf   r  rf   r	  rf   r
  r_   r  r  r  r   r  r   r  rf   r  r_   r  r_   rs   r  r   r4   )Frg  rh  r   r@   r^   r   r   r   r   r   rR   rQ   rT   rS   r   r]   rV   rU   rb   r   re   r   rg   r   rX   rW   rZ   rY   r[   rU   r`   r   r   rY   r   rY   r   r   rj   ri   rk   rY   rl   rY   rm   rY   ro   rn   rp   r   rr   rq   r   r   rv   ru   rx   rY   rz   ry   r   r   r   rf   r   r   r}   r_   r   r:   r  )rG   rH   rI   rA  r   rB  r  r  r  r  r  r  r  rb  r  r   r   r/   rz  r  rm  r  r   r  r  r  r  r  r  r  r  r  s   @rM   r  r  b  s       KK
 26'+E E E E E E E EN    X    X
     ' ' ' '     
 
 
 
         OS&*&*'+CJ:>$($( -1""&915!;?'+&(DH $-1!!#% %26!&!& /$)-26M6 6 6 6 6J 6:RV&*)-)- $*.GNBF'+'+#04!%!%)</348! $"DH*.?F,.MQ#'6:!%(, %GT( T( T( T( T(t 6:RV&*)-)- $*.GNBF'+'+#04!%!%)</348! $"DH*.?F,.MQ#'6:!%(, %GU/ U/ U/ U/ U/nD D D DC C C CD D D DC C C CE E E EF F F FG G G GE E E EE E E E E E E ErL   r  )r   r@   r   r_   r   )r   r   )r   r   )rh   r   r   r   )f
__future__r   r  http.cookiesrB   r   r   r;  sysrQ  r  rY  collections.abcr   r   r   concurrent.futuresr   
contextlibr   r	   r
   dataclassesr   datetimer   ior   typingr   r   r   r   r   r   r   r   urllib.parser   aior   constr   r   r   r   r   r   r   r   utilsr    rT   r"   r#   r$   
exceptionsr%   r&   r'   rR   r(   r)   rj   r*   r+   r,   modelsr-   r.   r/   r0   r1   r2   
websocketsr3   r4   r5   r6   r7   version_infor:   typing_extensionsr=   r?   rP   r   r   r   dictr@   
ThreadTyperh  r   r   r   r   r   r   r   rE  r  rK   rL   rM   <module>rH     s   " " " " " "      				   



       ? ? ? ? ? ? ? ? ? ? 1 1 1 1 1 1 D D D D D D D D D D ! ! ! ! ! !            	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 " ! ! ! ! !       B B B B B B B B B B B B , , , , , , , , , , # # # # # # 5 5 5 5 5 5 5 5 5 5 C C C C C C C C C C ) ) ) ) ) ) ) ) K K K K K K K K K K ( ( ( ( ( ( ( ( L L L L L L L L L L L L              w8X666AA8$$$A Y>((((((    IU        GAJ	    @    iu    B    +5     
       
 WYYFS#XI!)2I&)*
P

; ; ; ;         ./ % % % % % % % %   (G) G) G) G) G)'!* G) G) G)TK? K? K? K? K?k!n K? K? K?\Z	E Z	E Z	E Z	E Z	E;q> Z	E Z	E Z	E Z	E Z	ErL   