
    i?*                        S SK Jr  S SKrS SKrS SKrS SKJr  S SKJrJ	r	J
r
  S SKJrJr  S SKJr  SSKJr  SS	KJr  S
SKJr  S
SKJrJr  S
SKJr   S SKJr  \" \5         S SKJr   S SK!r"SSS5        \RF                  " S5      r$\%" 5       r&S\RN                  4S jr( " S S5      r) " S S5      r*g! \ a	    S SKJr   Nhf = f! , (       d  f       N_= f)    )suppressN)Future)AnyOptionalUnion)	AwaitableCallable)	timedelta   )Curl)CurlCffiWarning   )Cookies)	HTTPErrorRequestException)Headers)loads)markdownifyzcharset=([\w-]+)qc                     U R                      U R                  R                  5         U R                  R	                  5         SU l        S S S 5        g ! , (       d  f       g = f)Nr   )mutexqueueclearall_tasks_done
notify_allunfinished_tasks)r   s    F/app/mltbenv/lib/python3.13/site-packages/curl_cffi/requests/models.pyclear_queuer      s:    	
		##% 
s   <A
A c                   .    \ rS rSrSrS\S\S\4S jrSrg)	Request%   zRepresenting a sent request.urlheadersmethodc                 (    Xl         X l        X0l        g )N)r"   r#   r$   )selfr"   r#   r$   s       r   __init__Request.__init__(   s        )r#   r$   r"   N)	__name__
__module____qualname____firstlineno____doc__strr   r'   __static_attributes__ r)   r   r    r    %   s    &C ' 3 r)   r    c                   Z   \ rS rSrSrSS\\   S\\   4S jjr\	S\
4S j5       r\	S\
4S	 j5       r\R                  S
\
SS4S j5       r\	S\\
   4S j5       r\	S\
4S j5       rS\
4S jrS\S\
4S jrS rSS jrSS jrS rS rSS jrSS jrS\
4S jrS\4S jrS rS\
4S jrSrg) Response.   a  Contains information the server sends.

Attributes:
    url: url used in the request.
    content: response body in bytes.
    text: response body in str.
    status_code: http status code.
    reason: http response reason, such as OK, Not Found.
    ok: is status_code in [200, 400)?
    headers: response headers.
    cookies: response cookies.
    elapsed: timedelta of the request duration.
    encoding: http body encoding.
    charset: alias for encoding.
    primary_ip: primary ip of the server.
    primary_port: primary port of the server.
    local_ip: local ip used in this connection.
    local_port: local port used in this connection.
    charset_encoding: encoding specified by the Content-Type header.
    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.
    redirect_count: how many redirects happened.
    redirect_url: the final redirected url.
    http_version: http version used.
    history: history redirections, only headers are available.
    download_size: total downloaded bytes (body).
    upload_size: total uploaded bytes (body).
    header_size: total header size.
    request_size: request size.
    response_size: download_size + header_size
Ncurlrequestc                    Xl         X l        SU l        SU l        SU l        SU l        SU l        [        5       U l        [        5       U l
        [        5       U l        SU l        SU l        SU l        SU l        SU l        SU l        SU l        SU l        / U l        0 U l        S U l        S U l        S U l        S U l        SU l        SU l        SU l        SU l        SU l        g )N r)      OKTutf-8r   ) r5   r6   r"   contentstatus_codereasonokr   r#   r   cookiesr
   elapseddefault_encodingredirect_countredirect_urlhttp_version
primary_ipprimary_portlocal_ip
local_porthistoryinfosr   stream_taskastream_taskquit_nowdownload_sizeupload_sizeheader_sizerequest_sizeresponse_size)r&   r5   r6   s      r   r'   Response.__init__P   s    	yy"++DK!!" -/%'
,0
-115"# ! !!""#r)   returnc                     U R                   $ )zAlias for encoding.)encodingr&   s    r   charsetResponse.charseto   s     }}r)   c                 <   [        U S5      (       d  U R                  nUca  [        U R                  [        5      (       a  U R                  nO5[        U R                  5      (       a  U R                  U R                  5      nU=(       d    SU l        U R                  $ )a  
Determines the encoding to decode byte content into text.

The method follows a specific priority to decide the encoding:
1. If ``.encoding`` has been explicitly set, it is used.
2. The encoding specified by the ``charset`` parameter in the ``Content-Type``
    header.
3. The encoding specified by the ``default_encoding`` attribute. This can either
    be a string (e.g., "utf-8") or a callable for charset autodetection.
	_encodingr;   )hasattrcharset_encoding
isinstancerB   r/   callabler<   r\   )r&   rW   s     r   rW   Response.encodingt   s{     t[)),,Hd33S99#44Hd3344#44T\\BH%0DN~~r)   valuec                 H    [        U S5      (       a  [        S5      eXl        g )N_textz0Cannot set encoding after text has been accessed)r]   
ValueErrorr\   )r&   rb   s     r   rW   ra      s     4!!OPPr)   c                     U R                   R                  S5      nU(       a/  [        R                  U5      nU(       a  UR	                  S5      $ S$ g)z=Return the encoding, as specified by the Content-Type header.zContent-Typer   N)r#   get
CHARSET_REsearchgroup)r&   content_typecharset_matchs      r   r^   Response.charset_encoding   sF     ||''7&--l;M-:=&&q)DDr)   c                     [        U S5      (       dD  U R                  (       d  SU l        U R                  $ U R                  U R                  5      U l        U R                  $ )Nrd   r8   )r]   r<   rd   _decoderX   s    r   textResponse.text   sI    tW%%<<
 zz "\\$,,7
zzr)   c                     [         R                  " U R                  5      nUR                  5       nUR	                  SS9n[        SU SU S35      nU$ )NT)html_partialz<h1>z</h1><main>z</main>)rdDocumentr<   titlesummarymd)r&   docrv   rw   
body_as_mds        r   markdownResponse.markdown   sN    kk$,,'		++4+0$ug[	AB
r)   r<   c                      UR                  U R                  SS9$ ! [        [        4 a    UR                  S5      s $ f = f)Nreplace)errorsz	utf-8-sig)decoderW   UnicodeDecodeErrorLookupError)r&   r<   s     r   ro   Response._decode   sA    	/>>$--	>BB"K0 	/>>+..	/s    !A A c                 t    U R                   (       d'  [        SU R                   SU R                   3SU 5      eg)z2Raise an error if status code is not in [200, 400)zHTTP Error z: r   N)r?   r   r=   r>   rX   s    r   raise_for_statusResponse.raise_for_status   s6    wwk$*:*:);2dkk]KQPTUU r)   c              #   4  #    SnU R                  XS9 Hu  nUb  XE-   nU(       a  UR                  U5      OUR                  5       nU(       a0  US   (       a&  U(       a  US   S   US   :X  a  UR                  5       OSnU Sh  vN   Mw     Ub  Uv   gg N7fz
iterate streaming content line by line, separated by ``\n``.

Copied from: https://requests.readthedocs.io/en/latest/_modules/requests/models/
which is under the License: Apache 2.0
N)
chunk_sizedecode_unicode)iter_contentsplit
splitlinespop)r&   r   r   	delimiterpendingchunkliness          r   
iter_linesResponse.iter_lines   s      &&! ' 
E ".7EKK	*U=M=M=OE U2Y5U2Yr]eBi5O 		  
 M  s   BBBBc              #   x  #    U(       a  [         R                  " S[        SS9  U(       a
  [        5       eU R                  (       a  U R
                  (       d   S5       e U R                  R                  5       n[        U[        5      (       a  U R
                  R                  5         UeU[        L a  gUv   M[  7fz4
iterate streaming content chunk by chunk in bytes.
z9chunk_size is ignored, there is no way to tell curl that.r   )
stacklevelzstream mode is not enabled.N)warningswarnr   NotImplementedErrorr   r5   rg   r_   r   reset
STREAM_ENDr&   r   r   r   s       r   r   Response.iter_content   s      MMK
 %''zzdiiF)FF'JJNN$E %!122		! 
"K s   B8B:c                 .    [        U R                  40 UD6$ )z+return a parsed json object of the content.)r   r<   )r&   kws     r   jsonResponse.json   s    T\\(R((r)   c                     U R                   (       a  U R                   R                  5         U R                  (       a  U R                  R                  5         ggz:Close the streaming connection, only valid in stream mode.N)rN   setrL   resultrX   s    r   closeResponse.close   s;     ==MM##% r)   c                H  #    SnU R                  XS9  Sh  vN nUb  XE-   nU(       a  UR                  U5      OUR                  5       nU(       a0  US   (       a&  U(       a  US   S   US   :X  a  UR                  5       OSnU H  nU7v   M
     M   N|
 Ub  U7v   gg7fr   )aiter_contentr   r   r   )r&   r   r   r   r   r   r   lines           r   aiter_linesResponse.aiter_lines   s      --! . 
 	% ".7EKK	*U=M=M=OE U2Y5U2Yr]eBi5O 		  
 	 
 M s&   B"BBBA9B"BB"c                  #    U(       a  [         R                  " S[        SS9  U(       a
  [        5       eU R                  (       a  U R
                  (       d   S5       e U R                  R                  5       I Sh  vN n[        U[        5      (       a  U R                  5       I Sh  vN   UeU[        L a  U R                  5       I Sh  vN   gU7v   Mz   N\ N1 N7fr   )r   r   r   r   r   r5   rg   r_   r   acloser   r   s       r   r   Response.aiter_content  s      MMK
 %''zzdiiF)FF'**..**E %!122kkm## 
"kkm##K * $
 $s6   A:C<C=,C)C*"CCCCCc                 \   #    U R                  U R                  5       I Sh  vN 5      $  N7f)z
Return a decoded string.
N)ro   acontentrX   s    r   atextResponse.atext0  s"      ||$--/1221s   ,*	,c                    #    / nU R                  5         Sh  vN nUR                  U5        M   N
 SR                  U5      $ 7f)z8wait and read the streaming content in one bytes object.Nr)   )r   appendjoin)r&   chunksr   s      r   r   Response.acontent6  s@     --/ 	!%MM% 	!/xxs   A313A3Ac                 \   #    U R                   (       a  U R                   I Sh  vN   gg N7fr   )rM   rX   s    r   r   Response.aclose=  s'      #### #s   !,*,c                 "    SU R                    S3$ )Nz<Response [z]>)r=   rX   s    r   __repr__Response.__repr__D  s    T--.b11r)   )r\   rd   rM   r<   r@   r5   rB   rO   rA   rQ   r#   rJ   rE   rK   rH   rI   r?   rF   rG   r   rN   r>   rC   rD   r6   rR   rS   r=   rL   rP   r"   )NN)NFN)NF)r*   r+   r,   r-   r.   r   r   r    r'   propertyr/   rY   rW   setterr^   rp   r{   bytesro   r   r   r   r   r   r   r   r   r   r   r   r0   r1   r)   r   r3   r3   .   s&   B$Xd^ $Xg=N $>    #  * __c d  
 (3-   c  # /u / /V
4:)&6<3S 3   $2# 2r)   r3   )+
contextlibr   r   rer   concurrent.futuresr   typingr   r   r   collections.abcr   r	   datetimer
   r5   r   utilsr   r@   r   
exceptionsr   r   r#   r   orjsonr   ImportErrorr   r   rx   readabilityrt   compilerh   objectr   Queuer   r    r3   r1   r)   r   <module>r      s      	  % ' ' /   #  3  k-  ZZ+,
X
5;;  W2 W27   s   B2  C2C C
C