o
    Z�¿j• ã                   @  sT  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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%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l0m1Z1m2Z2m3Z3 ddl4m5Z5 ddl6m7Z7m8Z8 ddl9m:Z:m;Z; ddl<m=Z=m>Z>m?Z? ddl@mAZAmBZB ddlCmDZDmEZEmFZF ddlGmHZH ddlImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZR ddl4mSZSmTZTmUZUmVZV ddlWmXZXmYZYmZZZm[Z[m\Z\ ej]dk�re$deHeHd�Z^ne$deHd�Z^e�rTej]dk�rd dlm_Z_ nd dl`m_Z_ dd lambZb G d!d"„ d"e#d#d$�ZcG d%d&„ d&e e^ e#d#d$�ZdG d'd(„ d(e#d#d$�ZeG d)d*„ d*eed#d$�ZfnG d+d,„ d,ƒZgegƒ Z_eheieif Zce#Zde#e#ZeZfe!d- Zje!d. ZkdBd3d4„Zle!d5 ZmeG d6d7„ d7ƒƒZndCd:d;„ZoG d<d=„ d=e e^ ƒZpG d>d?„ d?epe^ ƒZqG d@dA„ dAepe^ ƒZrdS )Dé    )ÚannotationsN)ÚAsyncGeneratorÚAsyncIterableÚCallableÚ	Generator)ÚThreadPoolExecutor)ÚasynccontextmanagerÚcontextmanagerÚsuppress)Ú	dataclass)Ú	timedelta)ÚBytesIO)	ÚTYPE_CHECKINGÚAnyÚGenericÚLiteralÚOptionalÚ	TypedDictÚTypeVarÚUnionÚcast)Úurlparseé   )Ú	AsyncCurl)Ú
CurlFollowÚCurlHttpVersionÚCurlInfoÚCurlOpt)ÚCurlÚ	CurlErrorÚCurlMime)ÚCurlCffiWarningé   )Ú	CacheSpecÚnormalize_cache_backend)ÚCookiesÚCookieTypes)ÚRequestExceptionÚSessionClosedÚ
code2error)ÚHeadersÚHeaderTypes)ÚBrowserTypeLiteralÚExtraFingerprintsÚExtraFpDict)ÚResponse)	Ú
STREAM_ENDÚRequestContentÚRequestDataÚSyncRequestContentÚ_AsyncIterableReaderÚ_capture_body_positionÚ_peek_aio_queueÚ_peek_queueÚ_rewind_body)ÚNOT_SETÚHttpVersionLiteralÚ
NotSetTypeÚset_curl_options)ÚAsyncWebSocketÚAsyncWebSocketContextÚ	WebSocketÚWebSocketErrorÚWebSocketRetryStrategy)é   é   ÚR)ÚboundÚdefault)rE   )rB   é   )ÚUnpack)ÚFingerprintc                   @  s6   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__© rV   rV   úU/home/dinkstrade/pdmp/venv/lib/python3.10/site-packages/curl_cffi/requests/session.pyrJ   T   s   
 rJ   F)Útotalc                   @  s  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< ded1< d2ed3< d4S )5Ú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ú5Optional[Union[BrowserTypeLiteral, str, Fingerprint]]ÚimpersonateÚja3ÚakamaiÚperkú/Optional[Union[ExtraFingerprints, ExtraFpDict]]Úextra_fpÚdefault_headersú"Union[str, Callable[[bytes], str]]Údefault_encodingÚcurl_optionszOptional[list]Ú
curl_infosú4Optional[Union[CurlHttpVersion, HttpVersionLiteral]]Úhttp_versionÚdebugÚ	interfaceÚdoh_urlú%Optional[Union[str, tuple[str, str]]]ÚcertúOptional[type[R]]Úresponse_classÚdiscard_cookiesÚraise_for_statusúOptional[CacheSpec]ÚcacheNrQ   rV   rV   rV   rW   rY   [   sB   
 rY   c                   @  s  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< ded1< d2ed3< d4ed5< d6ed7< d8ed9< d:S );ÚStreamRequestParamsú"Optional[Union[dict, list, tuple]]rg   úOptional[RequestData]ÚdataúOptional[RequestContent]ÚcontentúOptional[dict | list]ÚjsonrZ   r[   r\   r]   rf   Úfilesr^   r_   ú3Optional[Union[float, tuple[float, float], object]]rk   ú&Optional[Union[bool, CurlFollow, str]]rn   úOptional[int]rp   r`   ra   rb   rc   rd   úOptional[bool]ri   ÚrefererÚaccept_encodingúOptional[Callable]Úcontent_callbackrr   rs   rt   ru   rv   rw   rx   ry   rz   r{   úUnion[str, Literal[False]]Úquoter~   r   r�   r‚   rƒ   r„   ro   Úmax_recv_speedúOptional[CurlMime]Ú	multipartrh   r‡   NrQ   rV   rV   rV   rW   r‹   }   sD   
 r‹   c                   @  s   e Zd ZU ded< dS )ÚRequestParamsr—   ÚstreamNrQ   rV   rV   rV   rW   r¡       s   
 r¡   c                   @  s   e Zd Zedd„ ƒZdS )Ú_Unpackc                  O  s   d S ©NrV   )ÚargsÚkwargsrV   rV   rW   Ú__getitem__¦   s   z_Unpack.__getitem__N)rR   rS   rT   Ústaticmethodr§   rV   rV   rV   rW   r£   ¥   s    r£   )ÚeventletÚgevent)	ÚGETÚPOSTÚPUTÚDELETEÚOPTIONSÚHEADÚTRACEÚPATCHÚQUERYÚurlrK   Úreturnrh   c                 C  s   t | ƒ}t|jo
|jƒS )z,Check if the provided url is an absolute url)r   rh   ÚschemeÚhostname)r´   Ú
parsed_urlrV   rV   rW   Ú_is_absolute_url¶   s   r¹   ©ÚlinearÚexponentialc                   @  s:   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 )ÚRetryStrategyro   Úcountç        ÚfloatÚdelayÚjitterr»   ÚRetryBackoffÚbackoffN)rR   rS   rT   rU   rÁ   rÂ   rÄ   rV   rV   rV   rW   r½   ¿   s
   
 r½   rq   ú#Optional[Union[int, RetryStrategy]]c                 C  s†   | d u rd} t | tƒr| }nt | tƒrt| d�}ntdƒ‚|jdk r&tdƒ‚|jdk r/tdƒ‚|jdk r8tdƒ‚|jdvrAt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½   ro   Ú	TypeErrorr¾   Ú
ValueErrorrÁ   rÂ   rÄ   )rq   ÚstrategyrV   rV   rW   Ú_normalize_retryÇ   s    





rÊ   c                !   @  s¢   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ddœ dZd=d>„Zd[dFdG„ZdHdI„ Zd\dNdO„Zd]dRdS„Ze	d^dUdV„ƒZ
e
jd_dYdV„ƒZ
dS )`ÚBaseSessionzMProvide common methods for setting curl options and reading info in sessions.NTé   r   úutf-8F) r[   r]   r_   ra   rc   rd   re   rg   ri   rk   rl   rn   rp   rq   rs   rt   ru   rv   rx   ry   r{   r|   r}   r   r€   r�   r‚   r„   r†   r‡   rˆ   rŠ   r[   rZ   r]   r\   r_   r^   ra   r`   rc   rb   rd   re   rg   úOptional[dict[str, object]]ri   rh   rk   rj   rl   rn   rm   rp   ro   rq   rÅ   rs   rr   rt   ru   rv   rx   rw   ry   r{   rz   r|   úOptional[dict[CurlOpt, str]]r}   úOptional[list[object]]r   r~   r€   r�   r‚   r„   rƒ   r†   r…   r‡   rˆ   rŠ   r‰   c           !      C  sv  t |ƒ| _t|ƒ| _|| _|| _|| _|	| _|
| _|| _	|| _
|| _t|ƒ| _|| _|| _|| _|| _|| _|| _|| _|p?i | _|pDg | _|| _|| _|| _|| _|| _t| ƒ| _|d urmt|tƒdu rmt d|› d�ƒ‚|ppt| _!|| _"|| _#|r€|r€t dƒ‚|r†d|i}|p‰i | _$|| _%| jršt&| jƒsšt'dƒ‚d| _(| jdu s§| jd u r¹t)j* +d¡pµt)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'rL   z2You need to provide an absolute url for 'base_url'TÚREQUESTS_CA_BUNDLEÚCURL_CA_BUNDLE),r*   r[   r%   Ú_cookiesr_   re   rg   ri   rk   rl   rn   rp   rÊ   rq   rs   rt   ru   rv   rx   ry   r{   r|   r}   r   r€   r�   r‚   r„   r$   Ú_cacheÚ
issubclassr/   rÇ   r†   r‡   rˆ   ra   rd   r¹   rÈ   Ú_closedÚosÚenvironÚget)!Úselfr[   r]   r_   ra   rc   rd   re   rg   ri   rk   rl   rn   rp   rq   rs   rt   ru   rv   rx   ry   r{   r|   r}   r   r€   r�   r‚   r„   r†   r‡   rˆ   rŠ   rV   rV   rW   Ú__init__Þ   sf   
$




þÿ


ÿýÿzBaseSession.__init__Úcurlr   Úbufferr   Úheader_bufferrµ   rD   c           %      C  s˜  |}t t|  |¡ƒ}t t| tj¡ƒ ¡ |_|r| 	¡ |_
t t| tj¡ƒ|_t t| tj¡ƒ|_d|j  ko;dk n  |_| 	¡  ¡ }g }	g }
d}d}|D ]T}| ¡ sVqO| d¡r‹|re|
 |||	f¡ zt|jdd�d ƒ}W n ttfy~   d}Y nw | |¡jd	d
�}g }	qO| d¡s•| d¡rž|	d  |7  < qO|	 |¡ qO|r®|
 |||	f¡ |
r¸|
d \}|_}	t|	ƒ|_t tt | tj¡ƒ}d}|D ]t}z| dd¡\}}t|ƒ}W n ttfyç   Y qÌw |jd	d
�}d}tƒ }t|t |
ƒƒD ]}|
| \}}}||k�r|}t|ƒ}|d } nqút t|  d ¡ƒ}||_||_||_d|  k�o0dk n  |_||_||_!|j" |¡ qÌt#ƒ |_$|j %d¡}|D ]=}z0t&j$ '¡ }| (|¡ | )¡ D ]\} }!|j$j*| |!j+|! ,dd¡|! ,dd¡t-|! ,d¡ƒd� �q^W �qM t.�yŠ   Y �qMw |�p�| j/}|�s¥t tt | tj0¡ƒ}"| j1 2|"¡ t t| tj3¡ƒ ¡ |_4t t| tj5¡ƒ|_6t t| tj7¡ƒ ¡ |_8t t| tj9¡ƒ|_:||_!t;t t<| tj=¡ƒd�|_>t t| tj?¡ƒ|_@t t| tjA¡ƒ}#z|# ¡ |_BW n tC�y   |# d¡|_BY nw t t| tjD¡ƒ|_Et t| tjF¡ƒ|_Gt t| tjH¡ƒ|_It t| tjJ¡ƒ|_K|jE|jI |_L| jMD ]}$| |$¡|jN|$< �q>|S )NéÈ   i�  r   Ú s   HTTP/r   )Úmaxsplitr"   Úreplace)Úerrorsó    ó   	éÿÿÿÿz
set-cookieÚdomainÚpathú/Úsecure)rè   ré   rë   )Úsecondszlatin-1)Or   rD   r†   ÚbytesÚgetinfor   ÚEFFECTIVE_URLÚdecoder´   Úgetvaluer�   ro   ÚHTTP_VERSIONr   ÚRESPONSE_CODEÚstatus_codeÚokÚ
splitlinesÚstripÚ
startswithÚappendÚsplitÚ
IndexErrorrÈ   Úget_reason_phraseÚreasonr*   r[   ÚlistÚREDIRECT_HISTORYrÇ   ÚrangeÚlenr{   Úhistoryr%   r]   Úget_listrM   ÚSimpleCookieÚloadÚitemsÚsetÚvaluerÚ   rh   Ú	Exceptionr‡   ÚCOOKIECHANGESrÔ   Ú update_cookies_from_curl_changesÚ
PRIMARY_IPÚ
primary_ipÚPRIMARY_PORTÚprimary_portÚLOCAL_IPÚlocal_ipÚ
LOCAL_PORTÚ
local_portr   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_sizer}   Úinfos)%rÛ   rÝ   rÞ   rß   r{   r‡   ÚcÚrspÚheader_linesÚheader_listÚheader_blocksÚheader_statusÚheader_reasonÚheader_lineÚ_Úredirect_historyÚblock_indexÚitemÚstatus_bytesÚhistory_url_bytesÚhistory_statusÚhistory_urlÚhistory_reasonÚhistory_headersÚindexÚstatusrý   r[   Úhistory_responseÚset_cookie_headersÚ
set_cookieÚcookieÚnameÚmorselÚchangesÚredirect_url_bytesÚinforV   rV   rW   Ú_parse_response;  sÚ   

ÿ
ÿ
ÿ
ü




ûÿÿÿ
zBaseSession._parse_responsec                 C  s   | j rtdƒ‚d S )Nz'Session is closed, cannot send request.)r×   r(   ©rÛ   rV   rV   rW   Ú_check_session_closed¹  s   ÿz!BaseSession._check_session_closedr¢   r—   r›   úOptional[Callable[..., object]]c                C  s    t | jo| jj|t |ƒ|d�ƒS )N©r¢   r›   )rh   rÕ   Úshould_cache_request)rÛ   Úrequestr¢   r›   rV   rV   rW   Ú_cache_enabled½  s   ýþzBaseSession._cache_enabledÚattemptrÀ   c                 C  sJ   | j }|jdkr|jd|d   }n|j| }|jr#|t d|j¡7 }|S )Nr¼   r   r"   r¿   )rq   rÄ   rÁ   rÂ   ÚrandomÚuniform)rÛ   rJ  rÉ   rÁ   rV   rV   rW   Ú_retry_delayÍ  s   

zBaseSession._retry_delayr%   c                 C  s   | j S r¤   )rÔ   rC  rV   rV   rW   r]   ×  s   zBaseSession.cookiesr&   ÚNonec                 C  s   t |ƒ| _d S r¤   )r%   rÔ   )rÛ   r]   rV   rV   rW   r]   Û  s   )@r[   rZ   r]   r\   r_   r^   ra   r`   rc   rb   rd   r^   re   rb   rg   rÎ   ri   rh   rk   rj   rl   rh   rn   rm   rp   ro   rq   rÅ   rs   rr   rt   rb   ru   rb   rv   rb   rx   rw   ry   rh   r{   rz   r|   rÏ   r}   rÐ   r   r~   r€   rh   r�   rb   r‚   rb   r„   rƒ   r†   r…   r‡   rh   rˆ   rh   rŠ   r‰   )rÝ   r   rÞ   r   rß   r   r{   rz   r‡   rh   rµ   rD   )r¢   r—   r›   rE  rµ   rh   )rJ  ro   rµ   rÀ   )rµ   r%   )r]   r&   rµ   rN  )rR   rS   rT   Ú__doc__rÜ   rB  rD  rI  rM  Úpropertyr]   ÚsetterrV   rV   rV   rW   rË   Û   sV    Þ
]~


rË   c                "      s„  e Zd ZdZ			d�d‚‡ fdd„Zedd„ ƒZedd„ ƒZdd„ Zdƒdd„Z	dƒdd„Z
ed„d d!„ƒZ				d…d†d#d$„Zd‡d&d'„Zd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d,f"dˆdfdg„Zd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d,f"d‰dldm„ZdŠdodp„ZdŠdqdr„ZdŠdsdt„ZdŠdudv„ZdŠdwdx„ZdŠdydz„ZdŠd{d|„ZdŠd}d~„ZdŠdd€„Z‡  ZS )‹ÚSessionzšA 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_curlrh   r¦   úUnpack[BaseSessionParams[R]]rµ   rN  c                   s‚   t ƒ jdi |¤Ž || _|| _d| _d| _|r4t ¡ | _|r'd| _	|| j_
dS d| _	t| jd�| j_
dS |r8|nt| jd�| _dS )a  
        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 or fingerprint 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: interface name or local IP to bind to (bare IP = source address).
            doh_url: DNS-over-HTTPS server url, e.g. https://1.1.1.1/dns-query.
            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©r€   rV   )ÚsuperrÜ   Ú_threadÚ_use_thread_local_curlÚ_queueÚ	_executorÚ	threadingÚlocalÚ_localÚ_is_customized_curlrÝ   r   r€   Ú_curl)rÛ   rÝ   rT  rV  r¦   ©Ú	__class__rV   rW   rÜ   å  s   ?
zSession.__init__c                 C  sH   | j r!| jrtjdtdd� t| jdd ƒst| jd�| j_	| jj	S | j
S )Nz/Creating fresh curl handle in different thread.r   )Ú
stacklevelrÝ   rX  )r[  ra  ÚwarningsÚwarnr!   Úgetattrr`  r   r€   rÝ   rb  rC  rV   rV   rW   rÝ   4  s   ýzSession.curlc                 C  s   | j d u r	tƒ | _ | j S r¤   )r]  r   rC  rV   rV   rW   ÚexecutorC  s   
zSession.executorc                 C  s   | S r¤   rV   rC  rV   rV   rW   Ú	__enter__I  s   zSession.__enter__c                 G  s   |   ¡  d S r¤   ©Úclose©rÛ   r¥   rV   rV   rW   Ú__exit__L  s   zSession.__exit__c                 C  s   d| _ | j ¡  dS )úClose the session.TN)r×   rÝ   rl  rC  rV   rV   rW   rl  O  s   zSession.closeÚmethodÚ
HttpMethodr´   rK   úUnpack[StreamRequestParams]úGenerator[R, None, None]c                 k  s@   � | j d||dœ|¤ddi¤Ž}z
|V  W | ¡  dS | ¡  w )z6Equivalent to ``with request(..., stream=True) as r:``©rp  r´   r¢   TNrV   )rH  rl  ©rÛ   rp  r´   r¦   r&  rV   rV   rW   r¢   T  s
   €zSession.streamr?   c                 K  sŒ   |   ¡  | j ¡ }| j ¡  t|||||| jd�}ttdB | d¡ƒ}	|	dur6t| 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_closer€   Nr]   )rD  rÝ   Ú	duphandleÚresetr?   r€   r   r%   rÚ   r]   ÚupdateÚconnect)rÛ   r´   rv  rw  rx  ry  r¦   rÝ   rO   Úuser_cookiesÚmerged_cookiesrV   rV   rW   Ú
ws_connectb  s&   

ú




zSession.ws_connectro   c                 C  s
   | j  ¡ S r¤   )rÝ   ÚupkeeprC  rV   rV   rW   r�  •  s   
zSession.upkeepúgzip, deflate, brrÍ   rá   r   Frg   úDOptional[Union[dict[str, object], list[object], tuple[object, ...]]]rŽ   r�   r�   úOptional[SyncRequestContent]r’   r‘   r[   rZ   r]   r\   r“   rf   r_   r^   rk   r”   rn   r•   rp   r–   ra   r`   rc   rb   rd   ri   r—   r˜   r™   r›   rE  rs   rr   rt   ru   rv   rx   rw   ry   r{   rz   r�   rœ   r   ú+CurlHttpVersion | HttpVersionLiteral | Noner�   r‚   r„   rƒ   r¢   rž   r    rŸ   r‡   rD   c%           0   
     sè  |!rˆj  ¡ ‰ˆj  ¡ }%nˆj ‰tˆfi d|“d|“dˆj|g“dˆj“d|“d|“d|“dˆj|g“d	ˆj|g“d
|	“d|
pAˆj“d|t	u rJˆj
n|“d|d u rTˆjn|“d|d u r^ˆjn|“dˆj|g“d|“d|pnˆj“dˆj|g“d|“d|“d|“d|pƒˆj“d|p‰ˆj“d|p�ˆj“d|p•ˆj“d|p›ˆj“d|d u r¤ˆjn|“d|“d|p®ˆj“d|p´ˆj“d|pºˆj“d |!“d!|"“d"|#“d#| pÉˆj“d$ˆj“d%tj“d&tj“Ž\‰‰ ‰‰‰}&ˆjˆ|!|d'��rˆj j!ˆˆj"d(�}'|'d u�rˆ�sˆj#�sˆj $|'j%¡ ˆj&�r|' &¡  ˆ ¡  t't(|'ƒS |!�ri‡ ‡‡‡‡‡‡‡‡f	d)d*„}(ˆj) *|(¡})ˆ +¡  ˆ ,ˆˆ ˆˆˆ¡}*t-ˆƒ}+t.|+t/ƒ�rS|&�rI|& 0¡  |) 1¡  ˆ 2¡  |+‚ˆ|*_3|)|*_4|&|*_5ˆ|*_ˆj&�rg|* &¡  |*S z…z.ˆj6d+k�r}d,d l7},|,j8 9ˆj:¡ nˆj6d-k�r“d,d l;}-|- <¡ j= >ˆj:¡ !¡  nˆ :¡  W n+ t?�yÃ }. zˆ ,ˆˆ ˆˆˆ¡}*ˆ|*_3t@|.jAtB|.ƒƒ}/|/tB|.ƒ|.jA|*ƒ|.‚d }.~.ww ˆ ,ˆˆ ˆˆˆ¡}*ˆ|*_3ˆjˆ|!|d'��ràˆj  0ˆ|*¡ ˆj&�rè|* &¡  |*W ˆ ¡  S ˆ ¡  w ).Nrp  r´   Úparams_listre   rŽ   r�   r’   Úheaders_listÚcookies_listr“   r_   rk   rn   rp   Úproxies_listrc   rd   Úverify_listr˜   r™   r›   rs   rt   ru   rv   rx   ry   r�   r   r�   r‚   r¢   rž   r    r„   r|   Úqueue_classÚevent_classrF  )r†   c               
     sÐ   zQzˆ  ¡  W n2 ty9 }  z&ˆ ˆˆ ˆˆˆ¡}ˆ|_t| jt| ƒƒ}ˆ |t| ƒ| j|ƒ¡ W Y d } ~ nd } ~ ww W tt	j
ˆƒ ¡ sKtt	j
ˆƒ ¡  ˆ t¡ d S tt	j
ˆƒ ¡ sbtt	j
ˆƒ ¡  ˆ t¡ w r¤   )Úperformr   rB  rH  r)   ÚcoderK   Ú
put_nowaitr   r^  ÚEventÚis_setr  Úputr0   ©Úer&  Úerror©	rÞ   r%  r{   r‡   rß   Úheader_recvedÚqÚreqrÛ   rV   rW   r�    s$   
ÿ$€ú€þz&Session._request_once.<locals>.performr©   r   rª   )CrÝ   rz  r{  r<   rg   re   r[   rÔ   r_   r9   rk   rn   rp   ra   rd   ri   rs   rt   ru   rv   rx   ry   r   r�   r‚   r„   r|   ÚqueueÚQueuer^  r�  rI  rÕ   rÚ   r†   r‡   r|  r]   rˆ   r   rD   ri  ÚsubmitÚwaitrB  r7   rÆ   r'   r  Úresultrl  rH  Ústream_taskÚquit_nowrZ  Úeventlet.tpoolÚtpoolÚexecuter�  rª   Úget_hubÚ
threadpoolÚspawnr   r)   rŽ  rK   )0rÛ   rp  r´   rg   rŽ   r�   r’   r[   r]   r“   r_   rk   rn   rp   ra   rc   rd   ri   r˜   r™   r›   rs   rt   ru   rv   rx   ry   r{   r�   r   r�   r‚   r„   r¢   rž   r    r‡   r-  r   Úcached_responser�  rŸ  r&  Úfirst_elementr©   rª   r”  r•  rV   r–  rW   Ú_request_once˜  sB  *
ÿþý
üûúùø
	÷

öõ€ô€ó€ñ€î
ìë€ê
éèçæ€å€ä€ã€â€á!€ß#Ý$€Ü%€Û&€Ú'Ù(Ø)×*€Ö+Õ,Ô-Ó0þ


ÿ€
ÿ€ú
ÿÿzSession._request_oncerŒ   rš   ú0Optional[Union[BrowserTypeLiteral, Fingerprint]]r~   c%           *   	   C  sv  |   ¡  |dur
|n|}%t||ƒ}&| j}'t|'jd ƒD ]�}(|(dkr&t|%|&ƒ zu| 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&|#“d'|$“ŽW   S  ty¸   |(|'jkr¨‚ |  |(d ¡})|)r¶t	 
|)¡ Y qw dS ))zESend the request, see ``requests.request`` for details on parameters.Nr"   r   rp  r´   rg   rŽ   r�   r’   r[   r]   r“   r_   rk   rn   rp   ra   rc   rd   ri   r˜   r™   r›   rs   rt   ru   rv   rx   ry   r{   r�   r   r�   r‚   r„   r¢   rž   r    r‡   rV   )rD  r5   rq   r   r¾   r8   r©  r'   rM  ÚtimeÚsleep©*rÛ   rp  r´   rg   rŽ   r�   r’   r[   r]   r“   r_   rk   rn   rp   ra   rc   rd   ri   r˜   r™   r›   rs   rt   ru   rv   rx   ry   r{   r�   r   r�   r‚   r„   r¢   rž   r    r‡   ÚbodyÚbody_positionrÉ   rJ  rÁ   rV   rV   rW   rH  R  s´   )


ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ý$
Ü&

€ûÖzSession.requestúUnpack[RequestParams]c                 K  ó   | j dd|dœ|¤ŽS ©Nr°   rt  rV   ©rH  ©rÛ   r´   r¦   rV   rV   rW   Úhead±  ó   zSession.headc                 K  r±  ©Nr«   rt  rV   r³  r´  rV   rV   rW   rÚ   ´  r¶  zSession.getc                 K  r±  ©Nr¬   rt  rV   r³  r´  rV   rV   rW   Úpost·  r¶  zSession.postc                 K  r±  ©Nr­   rt  rV   r³  r´  rV   rV   rW   r’  º  r¶  zSession.putc                 K  r±  ©Nr²   rt  rV   r³  r´  rV   rV   rW   Úpatch½  r¶  zSession.patchc                 K  r±  ©Nr®   rt  rV   r³  r´  rV   rV   rW   ÚdeleteÀ  r¶  zSession.deletec                 K  r±  ©Nr¯   rt  rV   r³  r´  rV   rV   rW   ÚoptionsÃ  r¶  zSession.optionsc                 K  r±  ©Nr±   rt  rV   r³  r´  rV   rV   rW   ÚtraceÆ  r¶  zSession.tracec                 K  r±  ©Nr³   rt  rV   r³  r´  rV   rV   rW   ÚqueryÉ  r¶  zSession.query)NNT)
rÝ   rS  rT  rU  rV  rh   r¦   rW  rµ   rN  ©rµ   rN  )rp  rq  r´   rK   r¦   rr  rµ   rs  )NNNN)r´   rK   rµ   r?   )rµ   ro   )Jrp  rq  r´   rK   rg   rƒ  rŽ   r�   r�   r„  r’   r‘   r[   rZ   r]   r\   r“   rf   r_   r^   rk   r”   rn   r•   rp   r–   ra   r`   rc   rb   rd   r^   ri   r—   r˜   rb   r™   rb   r›   rE  rs   rr   rt   rb   ru   rb   rv   rb   rx   rw   ry   r—   r{   rz   r�   rœ   r   r…  r�   rb   r‚   rb   r„   rƒ   r¢   r—   rž   ro   r    rŸ   r‡   rh   rµ   rD   )Jrp  rq  r´   rK   rg   rŒ   rŽ   r�   r�   r„  r’   r‘   r[   rZ   r]   r\   r“   rf   r_   r^   rk   r”   rn   r•   rp   r–   ra   r`   rc   rb   rd   r^   ri   r—   r˜   rb   r™   rb   r›   rš   rs   rª  rt   rb   ru   rb   rv   rb   rx   rw   ry   r—   r{   rz   r�   rœ   r   r~   r�   rb   r‚   rb   r„   rƒ   r¢   r—   rž   ro   r    rŸ   r‡   rh   rµ   rD   ©r´   rK   r¦   r°  rµ   rD   )rR   rS   rT   rO  rÜ   rP  rÝ   ri  rj  rn  rl  r	   r¢   r€  r�  r9   r©  rH  rµ  rÚ   r¹  r’  r¼  r¾  rÀ  rÂ  rÄ  Ú__classcell__rV   rV   rc  rW   rR  á  sÊ    üO



ú
3	Ù ?Û
_






rR  c                %      sò  e Zd ZdZddddœdµ‡ fdd„Zed¶dd„ƒZed·dd„ƒZdd„ Zd¸dd„Z	d¹dd„Z
d d!„ Zdºd"d#„Zdºd$d%„Zd»d'd(„Zd¼d)d*„Zed½d1d2„ƒZd3ddddedddddddd4ddddddd5ddddd6d7d7d8d9dd:d;d<d9d3df%d¾dvdw„Zddddddddedddddddd4ddddddddxd5dddddd6dd9f"d¿d™dš„Zddddddddedddddddd4ddddddddxd5dddddd6dd9f"dÀd d¡„ZdÁd£d¤„ZdÁd¥d¦„ZdÁd§d¨„ZdÁd©dª„ZdÁd«d¬„ZdÁd­d®„ZdÁd¯d°„ZdÁd±d²„ZdÁd³d´„Z‡  ZS )ÂÚAsyncSessionzAAn async request session, cookies and connections will be reused.Né
   )ÚloopÚ
async_curlÚmax_clientsrÊ  ú asyncio.AbstractEventLoop | NonerË  úAsyncCurl | NonerÌ  ro   r¦   rW  rµ   rN  c                  sP   |  d¡durtdƒ‚tƒ jdi |¤Ž || _|| _|du | _|| _|  ¡  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 or fingerprint 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.
        rŠ   NzMAsyncSession does not support cache yet because CacheBackend I/O is blocking.rV   )	rÚ   ÚNotImplementedErrorrY  rÜ   Ú_loopÚ_acurlÚ_owns_acurlrÌ  Ú	init_pool)rÛ   rÊ  rË  rÌ  r¦   rc  rV   rW   rÜ   Ð  s   Bÿ
zAsyncSession.__init__úasyncio.AbstractEventLoopc                 C  s   | j du r
t ¡ | _ | j S )z"Returns a reference to event loop.N)rÐ  ÚasyncioÚget_running_looprC  rV   rV   rW   rÊ    s   

zAsyncSession.loopr   c                 C  s   | j d u rt| jd�| _ | j S )N)rÊ  )rÑ  r   rÊ  rC  rV   rV   rW   Úacurl&  s   
zAsyncSession.acurlc                 C  s:   t  | j¡| _	 z| j d ¡ W n t jy   Y d S w qr¤   )rÕ  Ú	LifoQueuerÌ  Úpoolr�  Ú	QueueFullrC  rV   rV   rW   rÓ  ,  s   ÿýzAsyncSession.init_poolr   c                 Ã  s0   �| j  ¡ I d H }|d u rt| jj| jd�}|S )N)Úcacertr€   )rÙ  rÚ   r   r×  Ú_cacertr€   ©rÛ   rÝ   rV   rV   rW   Úpop_curl4  s
   €zAsyncSession.pop_curlrÝ   úCurl | Nonec                 C  s<   t tjƒ� | j |¡ W d   ƒ d S 1 sw   Y  d S r¤   )r
   rÕ  rÚ  rÙ  r�  rÝ  rV   rV   rW   Ú	push_curl:  s   "ÿzAsyncSession.push_curlc                 Ã  s   �| S r¤   rV   rC  rV   rV   rW   Ú
__aenter__>  s   €zAsyncSession.__aenter__c                 Ç  s   �|   ¡ I d H  d S r¤   rk  rm  rV   rV   rW   Ú	__aexit__A  s   €zAsyncSession.__aexit__c                 Ã  sT   �| j r| j ¡ I dH  d| _	 z| j ¡ }|r| ¡  W n tjy(   Y dS w q)ro  NT)rÒ  r×  rl  r×   rÙ  Ú
get_nowaitrÕ  Ú
QueueEmptyrÝ  rV   rV   rW   rl  E  s   €
€ÿûzAsyncSession.closeú	list[int]c              
   Ã  s    �|   ¡  g }g }	 z| j ¡ }W n
 tjy   Y nw | |¡ |r.| | j d|j¡¡ q
zt	tj
|Ž I dH ƒW |D ]}|  |¡ q<S |D ]}|  |¡ qGw )aˆ  
        Performs connection upkeep for all idle connections in the pool.

        This is done by calling `curl_easy_upkeep` on each underlying curl handle.
        This function can be used to keep connections alive. For example, HTTP/2
        connections can be kept alive by sending PING frames.

        Returns:
            A list of curl return codes from `curl_easy_upkeep`.
        TN)rD  rÙ  rã  rÕ  rä  rù   rÊ  Úrun_in_executorr�  rþ   Úgatherrà  )rÛ   Úpooled_curlsÚtasksrÝ   rV   rV   rW   r�  R  s*   €ÿ
ù	
ÿÿzAsyncSession.upkeepc                 C  s<   |  ¡  | js| j |¡ | ¡  |  |¡ d S | ¡  d S r¤   )Úclean_handles_and_buffersr×   r×  Úremove_handler{  rà  rl  rÝ  rV   rV   rW   Úrelease_curlp  s   zAsyncSession.release_curlrp  rq  r´   rK   rr  úAsyncGenerator[R, None, None]c                 K sR   �| j d||dœ|¤ddi¤ŽI dH }z|V  W | ¡ I dH  dS | ¡ I dH  w )z<Equivalent to ``async with request(..., stream=True) as r:``rt  r¢   TNrV   )rH  Úacloseru  rV   rV   rW   r¢   y  s
   €$"zAsyncSession.streamTr‚  rá   r   é€   é@   Fg{®Gáz„?g{®Gázt?i  @ Ú	autocloserh   rg   ú<dict[str, object] | list[object] | tuple[object, ...] | Noner[   úHeaderTypes | Noner]   úCookieTypes | Noner_   útuple[str, str] | Nonerk   ú/float | tuple[float, float] | NotSetType | Nonern   úbool | CurlFollow | str | Nonerp   ú
int | Nonera   úProxySpec | Nonerc   ú
str | Nonerd   ri   úbool | Noner˜   r™   rs   ú-BrowserTypeLiteral | str | Fingerprint | Nonert   ru   rv   rx   ú&ExtraFingerprints | ExtraFpDict | Nonery   r�   ústr | Literal[False]r   r…  r�   r‚   r„   ú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_fullr|   údict[CurlOpt, str] | Noner>   c'           (   (     sd   d‡ ‡‡‡‡‡‡‡‡‡	‡
‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡ ‡!‡"‡#‡$‡%‡&f'd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 or fingerprint 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: interface name or local IP to bind to (bare IP = source address).
            doh_url: DNS-over-HTTPS server url, e.g. https://1.1.1.1/dns-query.
            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.01`` (10ms).
            send_time_slice: The maximum duration (in seconds) to process outgoing
                messages before yielding to the event loop.
                Defaults to ``0.005`` (5ms).
            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µ   r=   c                  “  s.  �ˆ   ¡  ˆ  ¡ I d H } td%i d| “dd“dˆ$“dˆ j“dˆ jˆg“dˆ jˆg“dˆ jˆg“d	ˆp3ˆ j“d
ˆ#tu r<ˆ j	nˆ#“dˆd u rFˆ j
nˆ“dˆd u rPˆ jnˆ“dˆ jˆg“dˆ“dˆp`ˆ j“dˆ jˆ%g“dˆ“dˆ “dˆprˆ j“dˆpxˆ j“dˆp~ˆ j“dˆp„ˆ j“dˆ
d u r�ˆ jnˆ
“dˆ“dˆp—ˆ j“dˆp�ˆ j“dˆp£ˆ j“dˆ“dˆp¬ˆ j“dtj“dtj“d ˆ	“d!ˆ“Ž}|  tjd"¡}|  tjd#¡}zˆ j  d | j!¡I d H }W n t"yé   |  #¡  ˆ  $d ¡ ‚ w t%t&t't( ˆ ƒ| ˆˆˆ!ˆˆˆ&ˆˆ"ˆˆˆˆ j)d$�}z| *¡  W |S  t+�y   | ,¡  ‚ w )&NrÝ   rp  r«   r´   re   r†  r‡  rˆ  r_   rk   rn   rp   r‰  rc   rd   rŠ  r˜   r™   rs   rt   ru   rx   ry   r�   r   r�   r‚   rž   r„   r‹  rŒ  r|   rv   r"   r   )rñ  r   r  r  r  r  r  r  r  r	  r
  r€   rV   )-rD  rÞ  r<   re   rg   r[   r]   r_   r9   rk   rn   rp   ra   rd   ri   rs   rt   ru   rx   ry   r   r�   r‚   r„   rÕ  r›  r�  Úsetoptr   ÚTCP_NODELAYÚCONNECT_ONLYrÊ  ræ  r�  r	  rl  rà  r=   r   rÈ  r/   r€   Ú_start_io_tasksr@   Ú	terminate)rÝ   r-  rO   ©'r™   ru   rn   r_   rñ  r
  r„   r  r]   r|   ry   r‚   r	  rx   r[   r   rs   r�   rt   r  rž   rp   r  rg   rv   ra   rc   rd   r�   r   r  r˜   rÛ   r  r  rk   r´   ri   r  rV   rW   Ú_connect_coroø  sê   €ÿþýü
û
ú
ù€ø	€÷€õ€ò
ðï€î
íìë€ê€é€è€ç€åã€â€á €à!ß"€Þ#Ý$Ü%Û&Ú(þ
ýò
üþz.AsyncSession.ws_connect.<locals>._connect_coroN)rµ   r=   )r>   )(rÛ   r´   rñ  rg   r[   r]   r_   rk   rn   rp   ra   rc   rd   ri   r˜   r™   rs   rt   ru   rv   rx   ry   r�   r   r�   r‚   r„   rž   r   r  r  r  r  r  r  r  r	  r
  r|   r  rV   r  rW   r€  ‡  s   Zq
RzAsyncSession.ws_connectrÍ   rŒ   rŽ   r�   r�   r�   r’   r‘   rZ   r\   r“   rf   r^   r”   r•   r–   r`   rb   r—   r›   rš   rr   rw   r{   rz   rœ   r~   rƒ   r¢   r    rŸ   r‡   rD   c%           .      ƒ  sÎ  �ˆ
  ¡ I d H ‰d ‰ |}%t|tƒrt|ˆƒ‰ ttˆ ƒ}%zÒtd0i dˆ“d|“d|“dˆ
j|g“dˆ
j“d|“d|%“d|“d	ˆ
j	|g“d
ˆ
j
|g“d|	“d|
pOˆ
j“d|tu rXˆ
jn|“d|d u rbˆ
jn|“d|d u rlˆ
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|d u r²ˆ
jn|“d|“d|p¼ˆ
j“d|pÂˆ
j“d |pÈˆ
j“d!|!“d"|"“d#|#“d$| p×ˆ
j“d%ˆ
j“d&tj“d'tj “Ž\‰	‰‰‰‰}&W n t!yú   ˆ
 "ˆ¡ ‚ w ˆ d u�rˆ  #¡  |!�rsˆ
j$ %ˆ¡‰d(‰d1‡ ‡‡‡‡‡‡‡‡	‡
‡fd+d,„}'‡‡‡
fd-d.„}(t &|'ƒ ¡})|) '|(¡ ttj ˆƒ (¡ I d H  ˆ
 )ˆˆˆˆˆ¡}*t*ˆƒ}+t|+t+ƒ�r]ˆ�sYˆ
 "ˆ¡ d/‰|+‚ˆ	|*_,|)|*_-|&|*_.ˆ|*_/ˆ
j0�rq|* 0¡  |*S zazˆ
j$ %ˆ¡‰ˆI d H  W n+ t1�y¬ }, zˆ
 )ˆˆˆˆˆ¡}*ˆ	|*_,t2|,j3t4|,ƒƒ}-|-t4|,ƒ|,j3|*ƒ|,‚d },~,ww ˆ
 )ˆˆˆˆˆ¡}*ˆ	|*_,ˆ
j0�rÁ|* 0¡  |*W ˆ d u�rÏˆ  5¡ I d H  ˆ
 "ˆ¡ S ˆ d u�ráˆ  5¡ I d H  ˆ
 "ˆ¡ w )2NrÝ   rp  r´   r†  re   rŽ   r�   r’   r‡  rˆ  r“   r_   rk   rn   rp   r‰  rc   rd   rŠ  r˜   r™   r›   rs   rt   ru   rv   rx   ry   r�   r   r�   r‚   r¢   rž   r    r„   r|   r‹  rŒ  Frµ   rN  c               
   “  s  �z`zˆ
I d H  W n2 t y; }  z&ˆ	 ˆˆˆˆˆ¡}ˆ|_t| jt| ƒƒ}ˆ |t| ƒ| j|ƒ¡ W Y d } ~ nd } ~ ww W ˆ d urHˆ  ¡ I d H  tt	j
ˆƒ ¡ sXtt	j
ˆƒ ¡  ˆ t¡I d H  d S ˆ d urmˆ  ¡ I d H  tt	j
ˆƒ ¡ s}tt	j
ˆƒ ¡  ˆ t¡I d H  w r¤   )r   rB  rH  r)   rŽ  rK   r�  rl  r   rÕ  r�  r‘  r  r’  r0   r“  )Úasync_readerrÞ   rÝ   r{   r‡   rß   r—  r˜  r™  rÛ   ÚtaskrV   rW   r�  ³  s.   €
ÿ$€ú€üz+AsyncSession._request_once.<locals>.performc                   s   ˆsˆ  ˆ ¡ d‰d S )NT)rì  )Úfut)rÝ   Úcurl_releasedrÛ   rV   rW   ÚcleanupÄ  s   
z+AsyncSession._request_once.<locals>.cleanupTrV   rÅ  )6rÞ  rÆ   r   r4   r   r3   r<   rg   re   r[   r]   r_   r9   rk   rn   rp   ra   rd   ri   rs   rt   ru   rv   rx   ry   r   r�   r‚   r„   r|   rÕ  r›  r�  ÚBaseExceptionrì  Ústartr×  Ú
add_handleÚcreate_taskÚadd_done_callbackr�  rB  r6   r'   rH  Úastream_taskr   rš  rˆ   r   r)   rŽ  rK   rl  ).rÛ   rp  r´   rg   rŽ   r�   r’   r[   r]   r“   r_   rk   rn   rp   ra   rc   rd   ri   r˜   r™   r›   rs   rt   ru   rv   rx   ry   r{   r�   r   r�   r‚   r„   r¢   rž   r    r‡   Úrequest_contentr   r�  r  rŸ  r&  r¨  r”  r•  rV   )r  rÞ   rÝ   r  r{   r‡   rß   r—  r˜  r™  rÛ   r  rW   r©  L  s:  €'


ÿþý
üûúùø
	÷

öõ€ô€ó€ñ€î
ìë€ê
éèçæ€å€ä€ã€â€á!€ß#Ý$€Ü%€Û&€Ú'Ù(Ø)×*€Ö+Õ,Ô-Ó0
þ
"

ÿ

ÿ€ú
ÿ

þzAsyncSession._request_onceúSOptional[Union[dict[str, str], list[tuple[str, str]], tuple[tuple[str, str], ...]]]ú*Optional[Union[dict[str, Any], list[Any]]]úOptional[dict[str, Any]]úOptional[Callable[..., Any]]rª  c%           *   	   Ã  s€  �|   ¡  |dur|n|}%t||ƒ}&| j}'t|'jd ƒD ]¡}(|(r%t|%|&ƒ zx| 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%|#“d&|$“ŽI dH W   S  ty½   |(|'jkrª‚ |  |(d ¡})|)r»t	 
|)¡I dH  Y qw dS )(zISend the request, see ``curl_cffi.requests.request`` for details on args.Nr"   rp  r´   rg   rŽ   r�   r’   r[   r]   r“   r_   rk   rn   rp   ra   rc   rd   ri   r˜   r™   r›   rs   rt   ru   rv   rx   ry   r{   r�   r   r�   r‚   r„   r¢   rž   r    r‡   rV   )rD  r5   rq   r   r¾   r8   r©  r'   rM  rÕ  r¬  r­  rV   rV   rW   rH  ý  s¶   €+


ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ý$Ü&
€ûÖzAsyncSession.requestr°  c                 Ë  ó   �| j dd|dœ|¤ŽI d H S r²  r³  r´  rV   rV   rW   rµ  ^  ó   €zAsyncSession.headc                 Ë  r#  r·  r³  r´  rV   rV   rW   rÚ   a  r$  zAsyncSession.getc                 Ë  r#  r¸  r³  r´  rV   rV   rW   r¹  d  r$  zAsyncSession.postc                 Ë  r#  rº  r³  r´  rV   rV   rW   r’  g  r$  zAsyncSession.putc                 Ë  r#  r»  r³  r´  rV   rV   rW   r¼  j  r$  zAsyncSession.patchc                 Ë  r#  r½  r³  r´  rV   rV   rW   r¾  m  r$  zAsyncSession.deletec                 Ë  r#  r¿  r³  r´  rV   rV   rW   rÀ  p  r$  zAsyncSession.optionsc                 Ë  r#  rÁ  r³  r´  rV   rV   rW   rÂ  s  r$  zAsyncSession.tracec                 Ë  r#  rÃ  r³  r´  rV   rV   rW   rÄ  v  r$  zAsyncSession.query)
rÊ  rÍ  rË  rÎ  rÌ  ro   r¦   rW  rµ   rN  )rµ   rÔ  )rµ   r   )rµ   r   )rÝ   rß  rµ   rN  rÅ  )rµ   rå  )rÝ   r   rµ   rN  )rp  rq  r´   rK   r¦   rr  rµ   rí  )Nr´   rK   rñ  rh   rg   rò  r[   ró  r]   rô  r_   rõ  rk   rö  rn   r÷  rp   rø  ra   rù  rc   rú  rd   rõ  ri   rû  r˜   rú  r™   rú  rs   rü  rt   rú  ru   rú  rv   rú  rx   rý  ry   rû  r�   rþ  r   r…  r�   rú  r‚   rú  r„   rÿ  rž   ro   r   ro   r  ro   r  ro   r  rh   r  r  r  rÀ   r  rÀ   r  ro   r	  rh   r
  rh   r|   r  rµ   r>   )Jrp  rq  r´   rK   rg   rŒ   rŽ   r�   r�   r�   r’   r‘   r[   rZ   r]   r\   r“   rf   r_   r^   rk   r”   rn   r•   rp   r–   ra   r`   rc   rb   rd   r^   ri   r—   r˜   rb   r™   rb   r›   rš   rs   rr   rt   rb   ru   rb   rv   rb   rx   rw   ry   r—   r{   rz   r�   rœ   r   r~   r�   rb   r‚   rb   r„   rƒ   r¢   r—   rž   ro   r    rŸ   r‡   rh   rµ   rD   )Jrp  rq  r´   rK   rg   r  rŽ   r�   r�   r�   r’   r   r[   rZ   r]   r\   r“   r!  r_   r^   rk   r”   rn   r•   rp   r–   ra   r`   rc   rb   rd   r^   ri   r—   r˜   rb   r™   rb   r›   r"  rs   rª  rt   rb   ru   rb   rv   rb   rx   rw   ry   r—   r{   rz   r�   rœ   r   r~   r�   rb   r‚   rb   r„   rƒ   r¢   r—   rž   ro   r    rŸ   r‡   rh   rµ   rD   rÆ  ) rR   rS   rT   rO  rÜ   rP  rÊ  r×  rÓ  rÞ  rà  rá  râ  rl  r�  rì  r   r¢   r9   r€  r©  rH  rµ  rÚ   r¹  r’  r¼  r¾  rÀ  rÂ  rÄ  rÇ  rV   rV   rc  rW   rÈ  Í  s   ûO





	Ù JÛ 8Ù
a






rÈ  )r´   rK   rµ   rh   )rq   rÅ   rµ   r½   )sÚ
__future__r   rÕ  Úhttp.cookiesrM   rØ   rš  rK  Úsysr^  r«  rf  Úcollections.abcr   r   r   r   Úconcurrent.futuresr   Ú
contextlibr   r	   r
   Údataclassesr   Údatetimer   Úior   Útypingr   r   r   r   r   r   r   r   r   Úurllib.parser   Úaior   Úconstr   r   r   r   rÝ   r   r   r    Úutilsr!   rŠ   r#   r$   r]   r%   r&   Ú
exceptionsr'   r(   r)   r[   r*   r+   rs   r,   r-   r.   Úmodelsr/   Ústreamsr0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   Ú
websocketsr=   r>   r?   r@   rA   Úversion_inforD   rH   Útyping_extensionsÚfingerprintsrI   rJ   rY   r‹   r¡   r£   ÚdictrK   Ú
ThreadTyperq  r¹   rÃ   r½   rÊ   rË   rR  rÈ  rV   rV   rV   rW   Ú<module>   s‚    ,,	"#
ÿ

     o