
    nbi!                   B   d Z 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
n# e$ r ddlZ
Y nw xY wddlZej        rddlmZ ddl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 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)m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0m1Z1 ddl2m3Z3m4Z4 ddl5m6Z6m7Z7m8Z8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZB ddl:mCZD ddl:mEZF ddlGmHZH ddlImJZK ddlImLZLmMZMmNZN ddlOmPZPmQZQmRZR ddlSmTZTmUZUmVZV ddlWmXZXmYZYmZZZm[Z[mEZE ddl\m]Z] ddl^m_Z_m`Z` ddlambZb ddlcmdZd ddlemfZf ddlgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZq edjr        edjs        edjt        edju        edjv        fZwdZxd Zyd!Zz G d" d#          Z{ G d$ d%          Z| G d& d'          Z} G d( d)          Z~ G d* d+e~          ZdS ),z`
requests.models
~~~~~~~~~~~~~~~

This module contains the primary objects that power Requests.
    )annotationsN)Literal)Mapping)	cookiejar)	CookieJar)UnsupportedOperation)	urlencodeurlsplit
urlunparse)
from_bytes   )AsyncBodyTypeAsyncHookTypeAsyncHttpAuthenticationTypeBodyFormTypeBodyTypeCookiesTypeHeadersTypeHookCallableTypeHookTypeHttpAuthenticationTypeHttpMethodTypeMultiPartFilesAltTypeMultiPartFilesTypeQueryParameterType)Headersparse_it)BearerTokenAuthHTTPBasicAuth)RequestsCookieJar_copy_cookie_jarcookiejar_from_dictget_cookie_header)ChunkedEncodingErrorConnectionErrorContentDecodingError	HTTPErrorInvalidJSONError
InvalidURLMultiplexingErrorStreamConsumedError)JSONDecodeError)SSLError)default_hooks)AsyncHTTPResponse)BaseHTTPResponseConnectionInfoResponsePromise)RawExtensionFromHTTP ServerSideEventExtensionFromHTTPWebSocketExtensionFromHTTP)AsyncRawExtensionFromHTTP%AsyncServerSideEventExtensionFromHTTPAsyncWebSocketExtensionFromHTTP)DecodeErrorLocationParseErrorProtocolErrorReadTimeoutErrorr-   )RequestField)choose_boundaryencode_multipart_formdata)	parse_url)codes)CaseInsensitiveDict)
astream_decode_response_unicodeget_auth_from_urlguess_filenameiter_slicesparse_header_linksparse_schemerequote_uristream_decode_response_unicode	super_lento_key_val_list   i (  c                  4    e Zd Zd Zedd            Zd	dZdS )
TransferProgressc                >    d| _         d | _        d| _        d| _        d S )Nr   F)totalcontent_lengthis_completed	any_errorselfs    _/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/niquests/models.py__init__zTransferProgress.__init__   s$    
*."'$    returnfloat | Nonec                T    | j         d S t          | j        | j         z  dz  d          S )Ng      Y@   )rS   roundrR   rV   s    rX   
percentagezTransferProgress.percentage   s/    &4dj4#66%?CCCrZ   strc                x    | j         rd| j         d| j         d| j          dS d| j         d| j        du rdnd dS )	Nz
<Progress z % (z / z)>z bytes sent (Fzin progress	completed)rS   r`   rR   rT   rV   s    rX   __repr__zTransferProgress.__repr__   sd     	\[[[TZ[[DDW[[[[uDJuudFW[`F`F`]]fquuuurZ   N)r[   r\   r[   ra   )__name__
__module____qualname__rY   propertyr`   rd    rZ   rX   rP   rP      sa        % % % D D D XDv v v v v vrZ   rP   c                  j    e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 d(d)dZed*d            Zd+dZd,d"Zd-d%Z	d.d'Z
dS )/Requesta{  A user-created :class:`Request <Request>` object.

    Used to prepare a :class:`PreparedRequest <PreparedRequest>`, which is sent to the server.

    :param method: HTTP method to use.
    :param url: URL to send.
    :param headers: dictionary of headers to send.
    :param files: dictionary of {filename: fileobject} files to multipart upload.
    :param data: the body to attach to the request. If a dictionary or
        list of tuples ``[(key, value)]`` is provided, form-encoding will
        take place.
    :param json: json for the body to attach to the request (if files or data is not specified).
    :param params: URL parameters to append to the URL. If a dictionary or
        list of tuples ``[(key, value)]`` is provided, form-encoding will
        take place.
    :param auth: Auth handler or (user, pass) tuple.
    :param cookies: dictionary or CookieJar of cookies to attach to this request.
    :param hooks: dictionary of callback hooks, for internal usage.

    Usage::

      >>> import niquests
      >>> req = niquests.Request('GET', 'https://httpbin.org/get')
      >>> req.prepare()
      <PreparedRequest [GET]>
    NmethodHttpMethodType | Noneurl
str | NoneheadersHeadersType | Nonefiles1MultiPartFilesType | MultiPartFilesAltType | NonedataBodyType | AsyncBodyType | NoneparamsQueryParameterType | Noneauth;HttpAuthenticationType | AsyncHttpAuthenticationType | NonecookiesCookiesType | NonehooksHookType | AsyncHookType | Nonejsontyping.Any | Nonebase_urlc                   |g n|}|g n|}|t                      n|}|i n|}|	i n|	}	t                      | _        t          |	                                          D ]\  }}|                     ||           || _        || _        || _        || _	        || _
        |
| _        || _        || _        || _        || _        d S )N)eventhook)rB   r.   r}   listitemsregister_hookrm   ro   rq   rs   ru   r   rw   ry   r{   r   )rW   rm   ro   rq   rs   ru   rw   ry   r{   r}   r   r   kvs                 rX   rY   zRequest.__init__   s     \rrtm+2?%'''~6m;H??
'' 	0 	0DAqQQ////
			 rZ   r[   r   c                *    t          | j                  S Nr   rq   rV   s    rX   oheaderszRequest.oheaders       %%%rZ   ra   c                    d| j          dS )Nz
<Request []>rm   rV   s    rX   rd   zRequest.__repr__   s    +DK++++rZ   r   r   aHookCallableType[Response | PreparedRequest] | list[HookCallableType[Response | PreparedRequest]]Nonec                "   || j         vrt          d| d          t          |          r"| j         |                             |           dS t	          |t
                    r,| j         |                             d |D                        dS dS )Properly register a hook..Unsupported event specified, with event name ""c              3  8   K   | ]}t          |          |V  d S r   callable.0hs     rX   	<genexpr>z(Request.register_hook.<locals>.<genexpr>   -      $D$D1$DQ$D$D$D$D$D$DrZ   N)r}   
ValueErrorr   append
isinstancer   extendrW   r   r   s      rX   r   zRequest.register_hook   s     
""VeVVVWWWD>> 	EJu$$T*****d## 	EJu$$$D$D$D$D$DDDDDD	E 	ErZ   ,HookCallableType[Response | PreparedRequest]boolc                j    	 | j         |                             |           dS # t          $ r Y dS w xY wziDeregister a previously registered hook.
        Returns True if the hook existed, False if not.
        TFr}   remover   r   s      rX   deregister_hookzRequest.deregister_hook   I    
	Ju$$T***4 	 	 	55	    $ 
22PreparedRequestc                    t                      }|                    | j        | j        | j        | j        | j        | j        | j        | j	        | j
        | j        | j                   |S )zXConstructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it.)rm   ro   rq   rs   ru   r   rw   ry   r{   r}   r   )r   preparerm   ro   rq   rs   ru   r   rw   ry   r{   r}   r   rW   ps     rX   r   zRequest.prepare   sf    			;L*;L*] 	 	
 	
 	
 rZ   NNNNNNNNNNN)rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   rp   r[   r   re   )r   ra   r   r   r[   r   )r   ra   r   r   r[   r   r[   r   )rf   rg   rh   __doc__rY   ri   r   rd   r   r   r   rj   rZ   rX   rl   rl      s         : )-&*CG04,0LP&*15"&#"! "! "! "! "!H & & & X&, , , ,E E E E	 	 	 	     rZ   rl   c                     e Zd ZU dZded<   d;dZed<d            Z	 	 	 	 	 	 	 	 	 	 	 d=d>dZd?d!Z	d@d"Z
dAd#Zd	d$dBd%ZdCd&Z	 dDdEd'ZdFd)Z	 dGdHd+ZdId,Zd;d-Zd;d.ZdJd1Zed?d2            Ze	 dDdKd6            ZedLd:            Zd	S )Mr   a0  The fully mutable :class:`PreparedRequest <PreparedRequest>` object,
    containing the exact bytes that will be sent to the server.

    Instances are generated from a :class:`Request <Request>` object, and
    should not be instantiated manually; doing so may produce undesirable
    effects.

    Usage::

      >>> import niquests
      >>> req = niquests.Request('GET', 'https://httpbin.org/get')
      >>> r = req.prepare()
      >>> r
      <PreparedRequest [GET]>

      >>> s = niquests.Session()
      >>> s.send(r)
      <Response HTTP/2 [200]>
    r   _pending_async_authr[   r   c                    d | _         d | _        d | _        d | _        d | _        t                      | _        d | _        d | _        d | _	        d | _
        d| _        d S )NF)rm   ro   rq   _cookiesbodyr.   r}   _body_position	conn_infoocsp_verifiedupload_progress_asynchronous_authrV   s    rX   rY   zPreparedRequest.__init__+  s`    -1#37 ?C59	;H??
3704*.8<(-rZ   r   c                *    t          | j                  S r   r   rV   s    rX   r   zPreparedRequest.oheadersD  r   rZ   Nrm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   +HookType[Response | PreparedRequest] | Noner   r   r   c                6   |                      |           |                     |||           |                     |           |                     |           |                     |||
           |                     |           |                     |	           dS )z6Prepares the entire request with the given parameters.r   N)prepare_methodprepare_urlprepare_headersprepare_cookiesprepare_bodyprepare_authprepare_hooks)rW   rm   ro   rq   rs   ru   rw   ry   r{   r}   r   r   s               rX   r   zPreparedRequest.prepareH  s      	F###fx888W%%%W%%%$t,,,$ 	5!!!!!rZ   ra   c                    d| j          dS )Nz<PreparedRequest [r   r   rV   s    rX   rd   zPreparedRequest.__repr__e  s    3DK3333rZ   c                   t                      }| j        |_        | j        |_        | j        | j                                        nd |_        t          | j                  |_        | j        |_        | j        |_        | j	        |_	        |S r   )
r   rm   ro   rq   copyr!   r   r   r}   r   r   s     rX   r   zPreparedRequest.copyh  ss    ;+/<+CDL%%'''	%dm44
*.rZ   c                @    |r|                                 n|| _        dS )zPrepares the given HTTP method.N)upperrm   )rW   rm   s     rX   r   zPreparedRequest.prepare_methods  s    (.:fllnnnFrZ   r   c          
     x   |
J d            |St          |d          dk    r>|                    d          r
|dd         }|                    d          sd| }||z   }t          |t                    r|                    d          }nt          |          }|                                }t          |                              d          s	|| _        dS 	 t          |          \  }}}}}}	}
n # t          $ r}t          |j         d}~ww xY w|st          d	|d
          |                    d          rt          d          |rd|vr"|s |s|                    d          s	|| _        dS |pd}|r|dz  }||z  }|r|d| z  }|sd}|r~t          |t                    r|                    d          }|                     |          }|r=t          |t          t          f          r|                    d          }|	r|	 d| }	n|}	t          t!          |||d|	|
g                    | _        dS )zPrepares the given HTTP URL.NzMissing URL in PreparedRequest )default/rN   utf8httpzInvalid URL z: No host supplied)*.zURL has an invalid label.%zxn--@:utf-8&)rH   endswith
startswithr   bytesdecodera   lstripro   r@   r:   r)   args_encode_params	bytearrayrI   r   )rW   ro   rw   r   schemery   hostportpathqueryfragmentenetloc
enc_paramss                 rX   r   zPreparedRequest.prepare_urlw  s     @C,,,22$$S)) -'}H~~c** $#c))Cn c5!! 	**V$$CCc((C jjll
 C  ++F33 	DHF	&>Gnn;FD$dE88! 	& 	& 	&af%%	&  	GECEEEFFF??:&& 	:8999 	4fT__]cMdMdDHF  	cMF$ 	!j$jj F  	D 	'&%(( 0w//,,V44J 'j5)*<== <!+!2!27!;!;J '$33z33EE&Ez664uh*WXXYYs   C4 4
D>DDc                N   t                      | _        |rt          |t                    r)| j                            t          |                     dS |                                D ]<}|\  }}t          |t                    r|                                }|| j        |<   ;dS dS )z Prepares the given HTTP headers.N)rB   rq   r   r   updater   r   r   )rW   rq   headernamevalues        rX   r   zPreparedRequest.prepare_headers  s     +,, 	/'4(( /##$7$@$@AAAAA%mmoo / /F"(KD%!$.. -#{{}}).DL&&	/ 	// /rZ   c           
     t   | j         J d}d}d}|s|d}i }t          t          d          sd|d<   	 t          j        |fi |}n## t          $ r}t          ||           d}~ww xY wt          |t                    r|                    d          }t          |d          pEt          t          |d	          t          |t          t          t          t          f           g          }	|	r	 t          |          }
n# t          t          t           f$ r d}
Y nw xY w|}|Nt          |d
          r>	 |                                | _        n## t&          $ r t)                      | _        Y nw xY w|rt+          d          |
rt          |
          | j         d<   n|r
d| j         d<   n|rXt          |t          t,          f          s"| t	          dt/          |           d          |                     ||          \  }}n|rd| j         v od| j         d         v }|rp|r_| j        j                            d          du r>| j        j                            d          | j        j                            d          nt;                      }nd}|                     ||          }t          |t                    st          |d          rd}n
|sd}nd| }t          |t          t,          f          du sJ |                     |           |rd| j         vr|| j         d<   n|r|r
|| j         d<   || _         dS )z"Prepares the given HTTP body data.NFzapplication/json;charset=utf-8orjson	allow_nan)requestr   	__aiter____iter__tellz1Streamed bodies and files are mutually exclusive.Content-LengthchunkedzTransfer-Encodingz@Conflicting parameters. Cannot pass files with given data: type()zcontent-typezmultipart/form-databoundary)boundary_for_multipartreadz!application/x-www-form-urlencodedzmultipart/form-data; boundary=zContent-Type)!rq   hasattr_jsondumpsr   r(   r   ra   encodeallr   tupler   rK   	TypeErrorAttributeErrorr   r   r   OSErrorobjectNotImplementedErrordicttype_encode_filesr   content_typehas_manygetr>   r   prepare_content_lengthr   )rW   ru   rs   r   r   r  enforce_form_datajson_kwargsve	is_streamlengthform_data_boundarys               rX   r   zPreparedRequest.prepare_body  s'    |''' 15#'! 	,( <LK5(++ 1+0K(9{477;77 9 9 9&r488889 $$$ ,{{7++D+.. 
#j))tc4%@AAA3
 3
	  L	<"4~/CD    DGD&$9$93*.))++D'' 3 3 3 +1((D'''3
  _)*]^^^ >14V-.. >4=01  'a   
w |$%uhlmqhrhr%u%u%uvvv'+'9'9%'F'F$|| a(6$,(F  )AK`dhdpq  eA  LA%( 	2  13 $ : C CJ O OSX X X $ : > >z J J V !M6:::FFF "1!2!2 +* .2*../A /  D "$,, af0E0E a'+0 a+NLL+`L^+`+`LdT4L11U::::''---  <t|!C!C/;^,, <"3 </;^,			s;   A 
A&A!!A&,C< <DD0E
 
E*)E*r   c                    | j         J |,t          |          }|rt          |          | j         d<   dS dS | j        dvr&| j                             d          d| j         d<   dS dS dS )z>Prepare Content-Length header based on request method and bodyNr   )GETHEAD0)rq   rK   ra   rm   r  )rW   r   r  s      rX   r  z&PreparedRequest.prepare_content_lengthQ  s    |'''t__F = 25V-...= = [//DL4D4DEU4V4V4^ .1DL)*** 0/4^4^rZ   r   c                   | j         
J d            |'t          | j                   }t          |          r|nd}|rt          |t                    rt          |          dk    r
t          | }n$t          |t                    rt          |          }t          |          st          d          t          |d          ot          j        |j                  pt          j        |          | _        | j        sF ||           }| j                            |j                   |                     | j                   dS || _        dS dS )z"Prepares the given HTTP auth data.NzACannot invoke prepare_auth method with incomplete PreparedRequest   zXUnexpected non-callable authentication. Did you pass unsupported tuple to auth argument?__call__)ro   rD   anyr   r  lenr   ra   r   r   r   r  asyncioiscoroutinefunctionr  r   __dict__r   r  r   r   )rW   ry   ro   url_authrs        rX   r   zPreparedRequest.prepare_auth`  s\    x##%h### <(22H"8}}688$D 	0$&& -3t99>>$d+D#&& -&t,,D>> } !{||| j))Xg.I$-.X.X'3,T22 # * 
0DJJ $$QZ000 ++DI66666+/(((1	0 	0rZ   c                    | j         
J d            t          |t          j                  r|| _        nt          |          | _        t          | j        |           }||| j         d<   dS dS )a  Prepares the given HTTP cookie data.

        This function eventually generates a ``Cookie`` header from the
        given cookies using cookielib. Due to cookielib's design, the header
        will not be regenerated if it already exists, meaning this function
        can only be called once for the life of the
        :class:`PreparedRequest <PreparedRequest>` object. Any subsequent calls
        to ``prepare_cookies`` will have no actual effect, unless the "Cookie"
        header is removed beforehand.
        Nz<method prepare_cookies must be invoked after prepare_headersCookie)rq   r   	cookielibr   r   r"   r#   )rW   r{   cookie_headers      rX   r   zPreparedRequest.prepare_cookies  sy     |'')g'''gy233 	9#DMM/88DM)$->>$%2DL""" %$rZ   c                P    |pg }|D ]}|                      |||                    dS )zPrepares the given hooks.N)r   )rW   r}   r   s      rX   r   zPreparedRequest.prepare_hooks  sC    
  	4 	4EueEl3333	4 	4rZ   c                   || j         vrt          d| d          t          |          r"| j         |                             |           dS t	          |d          r,| j         |                             d |D                        dS dS )r   r   r   r   c              3  8   K   | ]}t          |          |V  d S r   r   r   s     rX   r   z0PreparedRequest.register_hook.<locals>.<genexpr>  r   rZ   N)r}   r   r   r   r  r   r   s      rX   r   zPreparedRequest.register_hook  s     
""VeVVVWWWD>> 	EJu$$T*****T:&& 	EJu$$$D$D$D$D$DDDDDD	E 	ErZ   r   r   c                j    	 | j         |                             |           dS # t          $ r Y dS w xY wr   r   r   s      rX   r   zPreparedRequest.deregister_hook  r   r   c                   | j         J g }t          | j                   }|j        }|sd}|                    |           |j        }|r*|                    d           |                    |           d                    |          S )zBuild the path URL to use.Nr   ?r   )ro   r
   r   r   r   join)rW   ro   r   r   r   s        rX   path_urlzPreparedRequest.path_url  s     x###TXv 	D

4 	JJsOOOJJuwws||rZ   -QueryParameterType | BodyFormType | typing.IOr   str | bytes | bytearrayc           	     H   t          | t          t          t          f          r| S t	          | d          r|                                 S t	          | d          r*g }t          |           D ]\  }}t          |t          t          t          t          t          f          st	          |d          s3|-t          |t          t          f          st          |          g}n
|g}n||ng }|D ]o}|k|
                    t          |t                    r|                    d          n|t          |t                    r|                    d          n|f           p|rt          ||          d         S t          |d          S t          d	t          |            d
          )zEncode parameters in a piece of data.

        Will successfully encode parameters when passed as a dict or a list of
        2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
        if parameters are supplied as a dict.
        r   r   Nr   )r   r   T)doseqz9Function _encode_params got an unexpected type argument '')r   ra   r   r   r  r   rL   intfloatr   r   r  r?   r	   r   r  )ru   r   resultr   vsiterable_vsr   s          rX   r   zPreparedRequest._encode_params  s    dS%344 &	hKT6"" $	h99;;T:&& "	hF(..  2b3sE4"@AA ?QSU_I`I` ? ~j!/ /~ (+2wwi')d(*""BK$  A}5?35G5G N 1 1 1Q5?35G5G N 1 1 1Q   & 03     V40000fY]^bYcYcfffgggrZ   *MultiPartFilesType | MultiPartFilesAltTypeMdict[str | bytes, str | bytes] | list[tuple[str | bytes, str | bytes]] | Nonetuple[bytes, str]c           	        | st          d          t          |t                    rt          d          g }t          |pi           }t          | pi           }|D ]\  }}t          |t          t          f          st          |d          s|g}n|}|D ]}|t          |t                    st          |          }|                    t          |t                    r|                    d          n|t          |t                    r|                    d          n|f           |D ]:\  }	}
d}d}t          |
t          t          f          rbt          |
          dk    rt          |
          \  }}ntt          |
          dk    rt          |
          \  }}}nMt          |
          \  }}}}n8t          |
t          t          t          f          r|	}nt          |
          p|	}|
}t          |t          t          t          f          r|}nIt          |d          r|                                }n$|t          d	t          |           d
          	 |rt          |t                     r|                                }t%                      }t          |          D ]^\  }}t          |t                    r|                    d          }t          |t                    r|                    d          }|||<   _nd}n"# t&          $ r}t          d          |d}~ww xY wt)          |	|||          }|                    |           |                    |           <t-          |          \  }}||fS )a  Build the body for a multipart/form-data request.

        Will successfully encode files when passed as a dict or a list of
        tuples. Order is retained if data is a list of tuples but arbitrary
        if parameters are supplied as a dict.
        The tuples may be 2-tuples (filename, fileobj), 3-tuples (filename, fileobj, contentype)
        or 4-tuples (filename, fileobj, contentype, custom_headers).
        zFiles must be provided.zData must not be a string.r   Nr   r  r^   r   z?Unexpected fp type given for multipart form data preparation: 'r7  asciizlatin-1zDTried to prepare a form data but failed due to non-decodable headers)r   ru   filenamerq   )r  )r   r   ra   rL   r   r  r   r   r  r  r   r!  r   rE   r   r  r   to_dictr  UnicodeDecodeErrorr=   make_multipartr?   )rs   ru   
new_fieldsfieldsno_dict_filesfieldvaliterable_valr   fkeyfdescriptorftfhfnfpfdatafh_convertedfh_keyfh_valr   rfr   r  s                          rX   r  zPreparedRequest._encode_files  s     	;6777c"" 	;9:::=?
8G
PR8S8S,;EKR,H,H  	 	JE3  	# S*--	# !$u"!  =%a// #FF%%5?u5M5MXELL111SX1;As1C1CJAHHW---   "/ 6	" 6	"D+ "B%)B+t}55 ! {##q((";//FB%%**!&{!3!3JBBB%*;%7%7NBBkC	+BCC =BB'44<B "sE9566 pV$$ p		 !ncghjckck!n!n!nooop (!"g.. *ZZ\\#'66L*9"*=*= 6 6%fe44 <%+]]7%;%;F%fe44 >%+]]9%=%=F/5V,,6 $(L% p p p !ghhnoop 4eb,WWWB2...b!!!!6zBBl\!!s   B*L
L%L  L%r[   r   r   r   )rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r   r   r   r   rp   r[   r   re   r   )rm   rn   r[   r   )ro   rp   rw   rx   r   rp   r[   r   )rq   rr   r[   r   r   )ru   rv   rs   rt   r   r   r[   r   )r   rv   r[   r   )r   )ry   rz   ro   ra   r[   r   )r{   r|   r[   r   )r   ra   r[   r   )ru   r3  r   rp   r[   r4  )rs   r=  ru   r>  r[   r?  )rf   rg   rh   r   __annotations__rY   ri   r   r   rd   r   r   r   r   r   r  r   r   r   r   r   r2  staticmethodr   r  rj   rZ   rX   r   r     s?         ( 5444. . . .2 & & & X&
 )-&*CG04,0LP&*=A"&#" " " " ":4 4 4 4	 	 	 	; ; ; ;  $OZ OZ OZ OZ OZ OZb/ / / /& #'	x x x x xt1 1 1 1$ &0 &0 &0 &0 &0P3 3 3 3,4 4 4 4	E 	E 	E 	E	 	 	 	    X(  .21h 1h 1h 1h \1hf h" h" h" \h" h" h"rZ   r   c                      e Zd ZU dZg dZh dZded<   ded<   dHd
ZedId            Z	edJ fd            Z
dH fdZ fdZd Zd Z fdZd ZdKdZdJdZdLdZedJd            ZedJd            ZedJd            ZedMd            ZedNd             ZedOd"            Zej        	 dPdQd(            Zej        dRdSd+            Zed,fdTd.ZefdUd/Zej        	 	 	 dVdWd2            Zej        	 dRd#d3dXd4            Zed,d5fdYd6ZedZd8            Z edZd9            Z!ed[d;            Z"ed\d=            Z#d]d@Z$edA             Z%ed^dC            Z&d_dDZ'dHdEZ(d_dFZ)dHdGZ* xZ+S )`ResponsezhThe :class:`Response <Response>` object, which contains a
    server's response to an HTTP request.
    )
_contentstatus_coderq   ro   historyencodingreasonr{   elapsedr   >   okro   r   nexttextlinksr`  contentr{   ra  rq   r\  r_  
iter_linesis_redirectr]  iter_contentis_permanent_redirectr2   _promisezDtyping.Callable[[Response, PreparedRequest], PreparedRequest | None]_resolve_redirectr[   r   c                F   d| _         d| _        d | _        d | _        t	                      | _        t	                      | _        d | _        d | _        d | _	        g | _
        d | _        t          i           | _        t          j        d          | _        d | _        d | _        d S )NFr   )r\  _content_consumed_nextr]  rB   rq   trailersrawro   r_  r^  r`  r"   r{   datetime	timedeltara  r   download_progressrV   s    rX   rY   zResponse.__init__  s    7<',-1
 (,
 -@,A,A .A-B-B
 -1  $ %)
 (* #' #6b"9"9 ,4+=a+@+@ 04 ;?rZ   WebSocketExtensionFromHTTP | RawExtensionFromHTTP | ServerSideEventExtensionFromHTTP | AsyncWebSocketExtensionFromHTTP | AsyncRawExtensionFromHTTP | AsyncServerSideEventExtensionFromHTTP | Nonec                V    | j         !t          | j         d          r| j         j        ndS )a  Access the I/O after an Upgraded connection. E.g. for a WebSocket handler.
        If the server opened a WebSocket, then the extension will be of type WebSocketExtensionFromHTTP.
        Otherwise, on unknown protocol, it will be RawExtensionFromHTTP.
        Warning: If you stand in an async inclosure, the type
        will be AsyncWebSocketExtensionFromHTTP or AsyncRawExtensionFromHTTP.N	extensionrq  r  rw  rV   s    rX   rw  zResponse.extension  s2    & x#+(F(F# H	
rZ   r   c                n    	 t                                          d           dS # t          $ r Y dS w xY w)z
        Determine if response isn't received and is actually a placeholder.
        Only significant if request was sent through a multiplexed connection.
        rk  TF)super__getattribute__r  rW   	__class__s    rX   lazyzResponse.lazy  sG    	GG$$Z0004 	 	 	55	s   !& 
44c                    	 t                                          d           t                                          d                              |            dS # t          $ r Y dS w xY wz`internals used for lazy responses. Do not try to access this unless you know what you are doing.rk  
connectionN)rz  r{  gatherr  r|  s    rX   _gatherzResponse._gather  sn    	GG$$Z000GG$$\2299$????? 	 	 	DD	s   AA 
A('A(c                   	 t                                          d          |t          j        v rt                                          d          rpt	          j        t                                          d          j                  rt          d           t                                          d                       n# t          $ r Y nw xY wt                                          |          S )Nrq  r~  r  Accessing a lazy response produced by an AsyncSession is forbidden. Either call await session.gather() or set stream=True to produce an AsyncResponse that you can access directly.r  )	rz  r{  r[  __lazy_attrs__r"  r#  r  r*   r  rW   itemr}  s     rX   r{  zResponse.__getattribute__  s    	ww''..648CZ;Z;Z_d_f_f_w_wx~__;Z.uww/G/G/U/U/\]] :+8   8EGG,,Y77999 	 	 	D	 ww''---s   C C 
CCc                    | S r   rj   rV   s    rX   	__enter__zResponse.__enter__      rZ   c                .    |                                   d S r   close)rW   r   s     rX   __exit__zResponse.__exit__  s    

rZ   c                     j         r[t          j        t                                          d          j                  rt          d                                             j        s j	          fd j
        D             S )Nr  r  c                4    i | ]}|t          |d           S r   )getattr)r   attrrW   s     rX   
<dictcomp>z)Response.__getstate__.<locals>.<dictcomp>-  s'    KKKDgdD$//KKKrZ   )r~  r"  r#  rz  r{  r  r*   r  rn  rf  	__attrs__r|  s   `rX   __getstate__zResponse.__getstate__  s     9 	*577+C+CL+Q+Q+XYY '4   % 	LLKKKKDNKKKKrZ   c                    t          | dd           t          | dd            |                                D ]\  }}t          | ||           d S )Nrn  Trq  )setattrr   )rW   stater   r   s       rX   __setstate__zResponse.__setstate__/  sa    )4000eT""" ;;== 	' 	'KD%D$&&&&	' 	'rZ   ra   c                    | j         | j         j        | j         j        j        d| j         dS | j         j        j        j                            dd          }| j        rd| dS d| d| j         dS )	Nz<Response Dummy [r   z.0r   z<ResponsePromise >z
<Response z [)r   r   http_versionr]  r   replacer~  )rW   http_revisions     rX   rd   zResponse.__repr__7  s    <4<#9#AT\E[EhEp;t'7;;;; .;AII$PRSS9 	87}7777AMAAT-=AAAArZ   c                    | j         S )ak  Returns True if :attr:`status_code` is less than 400.

        This attribute checks if the status code of the response is between
        400 and 600 to see if there was a client error or a server error. If
        the status code, is between 200 and 400, this will return True. This
        is **not** a check to see if the response code is ``200 OK``.
        )rb  rV   s    rX   __bool__zResponse.__bool__C  s     wrZ   #typing.Generator[bytes, None, None]c                6    |                      t                    S )z,Allows you to use a response as an iterator.ri  ITER_CHUNK_SIZErV   s    rX   r   zResponse.__iter__M  s      111rZ   c                T    	 |                                   n# t          $ r Y dS w xY wdS )ax  Returns True if :attr:`status_code` is less than 400, False if not.

        This attribute checks if the status code of the response is between
        400 and 600 to see if there was a client error or a server error. If
        the status code is between 200 and 400, this will return True. This
        is **not** a check to see if the response code is ``200 OK``.
        FT)raise_for_statusr'   rV   s    rX   rb  zResponse.okQ  sC    	!!#### 	 	 	55	ts    
%%c                0    d| j         v o| j        t          v S )zTrue if this Response is a well-formed HTTP redirect that could have
        been processed automatically (by :meth:`Session.resolve_redirects`).
        location)rq   r]  REDIRECT_STATIrV   s    rX   rh  zResponse.is_redirect`  s    
 T\)Pd.>..PPrZ   c                R    d| j         v o| j        t          j        t          j        fv S )z@True if this Response one of the permanent versions of redirect.r  )rq   r]  rA   moved_permanentlypermanent_redirectrV   s    rX   rj  zResponse.is_permanent_redirectg  s4     T\) 
d.>#$C
 /
 	
rZ   PreparedRequest | Nonec                    | j         S )zTReturns a PreparedRequest for the next request in a redirect chain, if there is one.)ro  rV   s    rX   rc  zResponse.nexto  s     zrZ   ConnectionInfo | Nonec                V    | j         r!t          | j         d          r| j         j        S dS )zSProvide context to the established connection that was used to perform the request.r   N)r   r  r   rV   s    rX   r   zResponse.conn_infot  s1     < 	*GDL+>> 	*<))trZ   bool | Nonec                V    | j         r!t          | j         d          r| j         j        S dS )z4Marker that can inform you of the OCSP verification.r   N)r   r  r   rV   s    rX   r   zResponse.ocsp_verified{  s1     < 	.GDL/BB 	.<--trZ   .
chunk_sizer8  decode_unicodeLiteral[False]c                    d S r   rj   rW   r  r  s      rX   ri  zResponse.iter_content  s	     /2crZ   Literal[True]!typing.Generator[str, None, None]c                   d S r   rj   r  s      rX   ri  zResponse.iter_content  s    z}z}rZ   F)typing.Generator[bytes | str, None, None]c                `    d fd} j         r(t           j        t                    rt	                      5t          t
                    s t          dt                     d          t           j        pd          } |            } j         r|n|}|rt          |           S |S )	an  Iterates over the response data.  When stream=True is set on the
        request, this avoids reading the content at once into memory for
        large responses.  The chunk size is the number of bytes it should
        read into memory.  This is not necessarily the length of each item
        returned as decoding can take place.

        chunk_size must be of type int or None. A value of None will
        function differently depending on the value of `stream`.
        stream=True will read data as it arrives in whatever size the
        chunks are received. If stream=False, data is returned as
        a single chunk.

        If decode_unicode is True, content will be decoded using the best
        available encoding based on the response.

        We recommend setting chunk_size=-1 (default) to receive chunk as they come
        for performance purposes.
        r[   r  c               3  6  K   j         J t          j         d          ot          j         j        d          } | rYj        Rdj        v rIt                      _        	 t          j        d                   j        _        n# t          $ r Y nw xY wt          j         d          r	 j         	                    d          D ](}j        j         j        j
        j        _        |V  )n# t          $ r'}j        dj        _        t          |          d }~wt          $ r'}j        dj        _        t!          |          d }~wt"          $ r'}j        dj        _        t%          |          d }~wt&          $ r'}j        dj        _        t)          |          d }~ww xY w	 j                                       }|sn|V  "j         3t          j         d          rt-          j         j                  _        d_        d S )N_fpdata_in_countcontent-lengthstreamTdecode_contentrp  rq  r  r  rt  rq   rP   r8  rS   r   r  r  rR   r;   rU   r$   r9   r&   r<   r%   r-   RequestsSSLErrorr   rB   rp  rn  can_track_progresschunkr   r  rW   s      rX   generatez'Response.iter_content.<locals>.generate  si     8'''!(5!9!9!dgdhlTc>d>d! d&<&D#t|33-=-?-?D*@CDLQaDb@c@c.==%    tx**  .!%D!Q!Q $ $1=;?8<;UD28#$ % 2 2 2-9;?.8.q111" 2 2 2-9;?.8.q111' - - --9;?.8)!,,, . . .-9;?.8*1---.  HMM*55E  KKK	  x#*(E(E# 3DH4E F F%)D"""O   "$B 
BB.AC4 4
F2>"D  F2-"EF2"E>>F2"F--F2N+chunk_size must be an int, it is instead a r   rZ   r[   r  )
rn  r   r\  r   r+   r8  r  r  rF   rJ   )rW   r  r  r  reused_chunksstream_chunkschunkss   ``     rX   ri  zResponse.iter_content  s    ,.	* .	* .	* .	* .	* .	* .	*` ! 	_j&E&E 	_%'''#Jz3,G,G#]$zJZJZ]]]^^^#DM$8S*EE 

"&"8Km 	@1&$???rZ   c                4    d fd} j         r(t           j        t                    rt	                      5t          t
                    s t          dt                     d          t           j        pd          } j         r|n	 |            S )	a  Iterates over the response raw and possibly compressed data.
        When stream=True is set on the request, this avoids
        reading the content at once into memory for
        large responses. The chunk size is the number of bytes it should
        read into memory. This is not necessarily the length of each item
        returned as decoding can take place.

        chunk_size must be of type int or None. A value of None will
        function differently depending on the value of `stream`.
        stream=True will read data as it arrives in whatever size the
        chunks are received. If stream=False, data is returned as
        a single chunk.

        If decode_unicode is True, content will be decoded using the best
        available encoding based on the response.

        We recommend setting chunk_size=-1 (default) to receive chunk as they come
        for performance purposes.
        r[   r  c               3  6  K   j         J t          j         d          ot          j         j        d          } | rYj        Rdj        v rIt                      _        	 t          j        d                   j        _        n# t          $ r Y nw xY wt          j         d          r	 j         	                    d          D ](}j        j         j        j
        j        _        |V  )n# t          $ r'}j        dj        _        t          |          d }~wt          $ r'}j        dj        _        t!          |          d }~wt"          $ r'}j        dj        _        t%          |          d }~wt&          $ r'}j        dj        _        t)          |          d }~ww xY w	 j                                       }|sn|V  "j         3t          j         d          rt-          j         j                  _        d_        d S )	Nr  r  r  r  Fr  Trp  r  r  s      rX   r  z#Response.iter_raw.<locals>.generate  si     8'''!(5!9!9!dgdhlTc>d>d! d&<&D#t|33-=-?-?D*@CDLQaDb@c@c.==%    tx**  .!%E!R!R $ $1=;?8<;UD28#$ % 2 2 2-9;?.8.q111" 2 2 2-9;?.8.q111' - - --9;?.8)!,,, . . .-9;?.8*1---.  HMM*55E  KKK	  x#*(E(E# 3DH4E F F%)D"""r  Nr  r   rZ   r  )	rn  r   r\  r   r+   r8  r  r  rF   )rW   r  r  r  s   ``  rX   iter_rawzResponse.iter_raw  s    *.	* .	* .	* .	* .	* .	* .	*` ! 	_j&E&E 	_%'''#Jz3,G,G#]$zJZJZ]]]^^^#DM$8S*EE $ 6F}}HHJJFrZ   	delimiterstr | bytes | Nonec                    d S r   rj   rW   r  r  r  s       rX   rg  zResponse.iter_lines.  s	     /2crZ   r  c                   d S r   rj   r  s       rX   rg  zResponse.iter_lines6  s	     -0CrZ   Nc              #    K   |(|du r$t          |t                    rt          d          d}|                     ||          D ]x}|||z   }|r|                    |          }n|                                }|r7|d         r/|r-|d         d         |d         k    r|                                }nd}|E d{V  y||V  dS dS )zIterates over the response data, one line at a time.  When
        stream=True is set on the request, this avoids reading the
        content at once into memory for large responses.

        .. note:: This method is not reentrant safe.
        NFdelimiter MUST match the desired output type. e.g. if decode_unicode is set to True, delimiter MUST be a str, otherwise we expect a bytes-like variable.r  r  rN   r   ra   r   ri  split
splitlinespop)rW   r  r  r  pendingr  liness          rX   rg  zResponse.iter_lines?  s'       ^u%<%<IWZA[A[%<x  
 &&!. ' 
 
 	 	E "% +I..((** r u r2%)1K1K))++MMMMM rZ   r   c                n    | j         rt          | j                   }|dz  }|S t          | j                  S )a-  
        Retrieve headers as they were objects. There is no need to parse headers yourself.
        A simple Mapping isn't enough to quickly access and analyze them.
        Read the full documentation of object-oriented headers at https://jawah.github.io/kiss-headers/
        >>> import niquests
        >>> r = niquests.get("https://google.com")
        >>> r.oheaders.content_type.charset
        'ISO-8859-1'
        >>> r.oheaders.content_type
        'text/html; charset=ISO-8859-1'
        >>> r.oheaders.content_type[0]
        'text/html'
        z
Set-Cookie)rq  r   rq   )rW   rq   s     rX   r   zResponse.oheadersh  s<     8 	tx((G|#GN%%%rZ   c                j    | j         rt          | j         j                  S t          | j                  S )ze
        Retrieve trailers as they were objects. There is no need to parse headers yourself.
        )rq  r   rp  rV   s    rX   	otrailerszResponse.otrailers}  s1    
 8 	/DH-...&&&rZ   bytes | Nonec                   | j         du r| j        rt          d          | j        dk    s| j        d| _         n	 t          | j        d          r!| j                            d          | _         n| j                                        | _         nu# t          $ r}t          |          d}~wt          $ r}t          |          d}~wt          $ r}t          |          d}~wt          $ r}t          |          d}~ww xY wd| _        | j        3t          | j        d          rt          | j        j                  | _        | j         S )	z"Content of the response, in bytes.F2The content for this response was already consumedr   Nr  Tr  rp  )r\  rn  RuntimeErrorr]  rq  r  r   r;   r$   r9   r&   r<   r%   r-   r  rB   rp  rW   r   s     rX   rf  zResponse.content  sh    =E!!% Y"#WXXX1$$(8 $.tx22 8(,T(J(J(,$ 2 2 2.q111" 2 2 2.q111' - - -)!,,, . . .*1---. "&8GDHj$A$A/0ABBDM }s<   AB 
DB))D6CDC!!D.C==Drp   c                   | j         sdS | j        M	 t          j        | j                  }t	          |d          r|j        du rdS n# t          $ r
 d| _        Y nw xY w| j        Ct          | j                                                   }|r|j        | _        t          |          S | j        dS t          | j         | j        d          S )a  Content of the response, in unicode.

        If Response.encoding is None, encoding will be guessed using
        ``charset_normalizer``.

        The encoding of the response content is determined based solely on HTTP
        headers, following RFC 2616 to the letter. If you can take advantage of
        non-HTTP knowledge to make a better guess at the encoding, you should
        set ``r.encoding`` appropriately before accessing this property.
        r   N_is_text_encodingFr  errors
rf  r_  codecslookupr  r  LookupErrorr   bestra   )rW   infoencoding_guesss      rX   rd  zResponse.text  s     | 	2=$%}T]334!455  $:PTY:Y:Y4 % % % $%
 = '55::<<N + . 7>***= 44<yAAAAs   2A AAkwargs
typing.Anyc                4   | j         st          ddd          | j        st          | j         g d                                          }|c|j        | _        	 t          j        t          |          fi |S # t
          j        $ r%}t          |j	        |j
        |j                  d}~ww xY wd| _        | j        }|t          ddd          	 t          j        |fi |S # t
          j        $ r%}t          |j	        |j
        |j                  d}~ww xY w)	a"  Returns the json-encoded content of a response, if any.

        :param \*\*kwargs: Optional arguments that ``json.loads`` takes.
        :raises requests.exceptions.JSONDecodeError: If the response body does not
            contain valid json or if content-type is not about json.
        response content is not JSONr   r   rA  r   zutf-16zutf-32z	utf-16-lez	utf-16-bez	utf-32-lez	utf-32-becp_isolationNr   z&response cannot lead to decodable JSONrf  RequestsJSONDecodeErrorr_  r   r  r  loadsra   r,   msgdocposrd  )rW   r  r  r   plain_contents        rX   r   zResponse.json  s^    | 	Q)*H"aPPP} 	(
 (	 	 	   dff  ) . 7G ;s>':':EEfEEE, G G G1!%FFFG !(	 )*RTVXYZZZ	?;}77777$ 	? 	? 	? *!%>>>	?s0   A8 8B, B''B,C# #D2 DDc                    | j                             d          }i }|rCt          |          }|D ]1}|                    d          p|                    d          }|||<   2|S )z8Returns the parsed header links of the response, if any.linkrelro   )rq   r  rG   )rW   r   resolved_linksre  r  keys         rX   re  zResponse.links  ss     !!&)) 	+&v..E + +hhuoo8%&*s##rZ   
int | Nonec                ,    | j         r| j         j        ndS )zShortcut to negotiated HTTP version protocol. See HttpVersion from urllib3.future.
        It returns an integer. It is as follows:

        - 11 for HTTP/1.1
        - 20 for HTTP/2
        - 30 for HTTP/3
        N)rq  versionrV   s    rX   r  zResponse.http_version  s     $(85tx5rZ   c                   | j         | S d}t          | j        t                    rF	 | j                            d          }n1# t
          $ r | j                            d          }Y nw xY w| j        }d| j         cxk    rdk     rn n| j          d| d| j         }n)d| j         cxk    rd	k     rn n| j          d
| d| j         }|rt          ||           | S )z+Raises :class:`HTTPError`, if one occurred.Nr   r   z
iso-8859-1i  i  z Client Error: z
 for url: iX  z Server Error: )response)r]  r   r`  r   r   rD  ro   r'   )rW   http_error_msgr`  s      rX   r  zResponse.raise_for_status  s4    #Kdk5)) 
	!
:++G44% : : :++L99: [F$"((((S((((( $ 0]]]]SWS[]]NND$****s***** $ 0]]]]SWS[]]N 	;NT::::s   A $A)(A)c                   | j         du rY| j        Rt          j        | j        j                  s| j                                         nt          j        dt                     t          | j        dd          }| |             dS dS )zReleases the connection back to the pool. Once this method has been
        called the underlying ``raw`` object must not be accessed again.

        *Note: Should not normally need to be called explicitly.*
        FNzQuse 'async with response' to be able to cleanly close the response in async mode.release_conn)	rn  rq  r"  r#  r  warningswarnUserWarningr  rW   r  s     rX   r  zResponse.close;  s     !U**tx/C.tx~>>     g  
 tx>>#LNNNNN $#rZ   c                
   K   | S r   rj   rV   s    rX   
__aenter__zResponse.__aenter__N  s      rZ   c                
  K   | j         du rS| j        Lt          j        | j        j                  st          d          | j                                         d {V  t          | j        dd           }| |             d S d S )NFz@Attempted to use a synchronous response in an awaitable context.r  )rn  rq  r"  r#  r  r	  r  )rW   exc_typeexc_valexc_tbr  s        rX   	__aexit__zResponse.__aexit__Q  s      !U**tx/C.tx~>> b`aaa(.."""""""""tx>>#LNNNNN $#rZ   rW  )r[   ru  )r[   r   re   r  )r[   r  )r[   r  )r[   r  ..)r  r8  r  r  r[   r  .)r  r8  r  r  r[   r  )r  r8  r  r   r[   r  )r  r8  r[   r  ...)r  r8  r  r  r  r  r[   r  )r  r8  r  r  r  r  r[   r  )r  r8  r  r   r  r  r[   r  r   r[   r  r[   rp   r  r  r[   r  )r[   r	  )r[   r[  ),rf   rg   rh   r   r  r  rX  rY   ri   rw  r~  r  r{  r  r  r  r  rd   r  r   rb  rh  rj  rc  r   r   typingoverloadri  r  r  rg  r   r  rf  rd  r   re  r  r  r  r  r  __classcell__r}  s   @rX   r[  r[  r  s           I  N< [[[[5? 5? 5? 5?n 
 
 
 X
, 	 	 	 	 	 X	     . . . . .     L L L L L$' ' '
B 
B 
B 
B   2 2 2 2    X Q Q Q XQ 
 
 
 X
    X    X    X _FI2 2 2 2 _2 _}}}} _} !0T T T T Tl *9 LG LG LG LG LG\ _ ),(+	2 2 2 2 _2 _ 0
 ),0 0 0 0 0 _0 *$(,	' ' ' ' 'R & & & X&( ' ' ' X'    X@ $B $B $B X$BL1? 1? 1? 1?f   X  6 6 6 X6   <   &   	 	 	 	 	 	 	 	rZ   r[  c                  ~    e Zd ZU ded<   ded<   h dZed.d            Zd/d	Zd0dZd Z	 fdZ
d1dZej        	 d2d3d            Zej        	 d4d5d            Zedfd6dZefd7dZej        	 	 	 d8d9d!            Zej        	 d4dd"d:d#            Zedd$fd;d%Zed<d'            Zed=d)            Zd>d,Zd1d-Z xZS )?AsyncResponsezBaseAsyncHTTPResponse | Nonerq  zVtyping.Callable[[Response, PreparedRequest], typing.Awaitable[PreparedRequest | None]]rl  >   rb  ro   rc  re  r`  r{   ra  rq   r\  r_  rh  r]  rj  r[   BAsyncWebSocketExtensionFromHTTP | AsyncRawExtensionFromHTTP | Nonec                V    | j         !t          | j         d          r| j         j        ndS )a  Access the I/O after an Upgraded connection. E.g. for a WebSocket handler.
        If the server opened a WebSocket, then the extension will be of type AsyncWebSocketExtensionFromHTTP.
        Otherwise, on unknown protocol, it will be AsyncRawExtensionFromHTTP.Nrw  rx  rV   s    rX   rw  zAsyncResponse.extensionz  s2     x#+(F(F# H	
rZ   c                    | S r   rj   rV   s    rX   r  zAsyncResponse.__aenter__  r  rZ   typing.AsyncIterator[bytes]c               f   K   |                      t                     d {V 2 3 d {V }|W V  6 d S r   r  )rW   r  s     rX   r   zAsyncResponse.__aiter__  sg      !%!2!2?!C!CCCCCCC 	 	 	 	 	 	 	%KKKKK DCCs   0c                >   K   |                                   d {V  d S r   r  )rW   r  r  r  s       rX   r  zAsyncResponse.__aexit__  s,      jjllrZ   c                    |t           j        v r| j        rt          d          t	          t
          |                               |          S )NzAccessing a lazy async response produced by an AsyncSession is forbidden this way. Either call await session.gather() or await one of (text, json, content, iter_content, iter_line, etc..) that are awaitable.)r'  r  r~  r*   rz  r[  r{  r  s     rX   r{  zAsyncResponse.__getattribute__  sO    =///DI/#&  
 Xt$$55d;;;rZ   r   c                   K   t          | d          r2t          | d          r$| j                            |            d{V  dS dS dS r  )r  r  r  rV   s    rX   r  zAsyncResponse._gather  sk      4$$ 	/|)D)D 	//((...........	/ 	/ 	/ 	/rZ   .r  r8  r  r  "typing.AsyncGenerator[bytes, None]c                
   K   d S r   rj   r  s      rX   ri  zAsyncResponse.iter_content  s       .1SrZ   r   typing.AsyncGenerator[str, None]c               
   K   d S r   rj   r  s      rX   ri  zAsyncResponse.iter_content  s       ,/3rZ   Fr   (typing.AsyncGenerator[bytes | str, None]c                b   K    j         r                                  d {V  d fd} j        r(t           j        t
                    rt                      5t          t                    s t          dt                     d           |            }|rt          |           S |S )Nr[   r0  c                >  K   j         J t          j         d          ot          j         j        d          } | rYj        Rdj        v rIt                      _        	 t          j        d                   j        _        n# t          $ r Y nw xY w	 	 j         	                    d           d {V }j        j         j        j
        j        _        nu# t          $ r}t          |          d }~wt          $ r}t          |          d }~wt           $ r}t#          |          d }~wt$          $ r}t'          |          d }~ww xY w|sn|W V  ĉj         3t          j         d          rt)          j         j                  _        d_        d S )Nr  r  r  Tr  rp  rq  r  r  rt  rq   rP   r8  rS   r   r   r  rR   r;   r$   r9   r&   r<   r%   r-   r  rB   rp  rn  r  s      rX   r  z,AsyncResponse.iter_content.<locals>.generate  s      8'''!(5!9!9!dgdhlTc>d>d! d&<&D#t|33-=-?-?D*@CDLQaDb@c@c.==%   ."&(--
4-"P"PPPPPPPE-97;x|7Q.4$ 2 2 2.q111" 2 2 2.q111' - - -)!,,, . . .*1---.  %( x#*(E(E# 3DH4E F F%)D"""O   "$B 
BBAC 
E(C77EDE D//E<EEr  r   r[   r0  )r~  r  rn  r   r\  r   r+   r8  r  r  rC   )rW   r  r  r  r  s   ``   rX   ri  zAsyncResponse.iter_content  s       9 	!,,..       '	* '	* '	* '	* '	* '	* '	*R ! 	_j&E&E 	_%'''#Jz3,G,G#]$zJZJZ]]]^^^ 

 	H2=$GGGrZ   c                :   K    j         r                                  d {V  d fd} j        r(t           j        t
                    rt                      5t          t                    s t          dt                     d           |            S )Nr[   r0  c                >  K   j         J t          j         d          ot          j         j        d          } | rYj        Rdj        v rIt                      _        	 t          j        d                   j        _        n# t          $ r Y nw xY w	 	 j         	                    d           d {V }j        j         j        j
        j        _        nu# t          $ r}t          |          d }~wt          $ r}t          |          d }~wt           $ r}t#          |          d }~wt$          $ r}t'          |          d }~ww xY w|sn|W V  ĉj         3t          j         d          rt)          j         j                  _        d_        d S )Nr  r  r  TFr  rp  r7  r  s      rX   r  z(AsyncResponse.iter_raw.<locals>.generate  s      8'''!(5!9!9!dgdhlTc>d>d! d&<&D#t|33-=-?-?D*@CDLQaDb@c@c.==%   ."&(--
5-"Q"QQQQQQQE-97;x|7Q.4$ 2 2 2.q111" 2 2 2.q111' - - -)!,,, . . .*1---.  %( x#*(E(E# 3DH4E F F%)D"""r8  r  r   r9  )
r~  r  rn  r   r\  r   r+   r8  r  r  )rW   r  r  s   `` rX   r  zAsyncResponse.iter_raw  s       9 	!,,..       '	* '	* '	* '	* '	* '	* '	*R ! 	_j&E&E 	_%'''#Jz3,G,G#]$zJZJZ]]]^^^xzzrZ   r  r  c                
   K   d S r   rj   r  s       rX   rg  zAsyncResponse.iter_lines  s       .1SrZ   r  c               
   K   d S r   rj   r  s       rX   rg  zAsyncResponse.iter_lines"  s       ,/3rZ   Nc                 K   |(|du r$t          |t                    rt          d          d }|                     ||           d {V 2 3 d {V }|||z   }|r|                    |          }n|                                }|r7|d         r/|r-|d         d         |d         k    r|                                }nd }|D ]}|W V  6 ||W V  d S d S )NFr  r  rN   r  )rW   r  r  r  r  r  r  lines           rX   rg  zAsyncResponse.iter_lines+  sm       ^u%<%<IWZA[A[%<x  
 !%!2!2!. "3 "
 "
 
 
 
 
 
 
 	 	 	 	 	 	 	% "% +I..((** r u r2%)1K1K))++  




!
& MMMMMM s   Cr  c                  K   | j         r|                                  d {V  | j        du r| j        rt	          d          | j        dk    s| j        d | _        n	 t          | j        t                    r'| j        	                    d           d {V | _        nt          nu# t          $ r}t          |          d }~wt          $ r}t          |          d }~wt          $ r}t!          |          d }~wt"          $ r}t%          |          d }~ww xY w| j        3t'          | j        d          rt)          | j        j                  | _        d| _        | j        S )NFr  r   Tr  rp  )r~  r  r\  rn  r  r]  rq  r   BaseAsyncHTTPResponser   r	  r;   r$   r9   r&   r<   r%   r-   r  r  rB   rp  r  s     rX   rf  zAsyncResponse.contentO  s     9 	!,,..       =E!!% Y"#WXXX1$$(8 $.!$(,ABB &.2hmm4m.P.P(P(P(P(P(P(P% & % 2 2 2.q111" 2 2 2.q111' - - -)!,,, . . .*1---. 8GDHj$A$A/0ABBDM!% }s=   AB' '
D1C  DCD)C88DDDrp   c                  K   | j          d {V }|sdS | j        M	 t          j        | j                  }t	          |d          r|j        du rd S n# t          $ r
 d | _        Y nw xY w| j        >t          |                                          }|r|j        | _        t          |          S | j        d S t          || j        d          S )Nr   r  Fr  r  r  )rW   rf  r  r  s       rX   rd  zAsyncResponse.textr  s      $$$$$$ 	2=$%}T]334!455  $:PTY:Y:Y4 % % % $%
 = '005577N + . 7>***= 47DM)<<<<s   2A A%$A%r  r  c                J  K   | j          d {V }|st          ddd          | j        st          |g d                                          }|c|j        | _        	 t          j        t          |          fi |S # t
          j        $ r%}t          |j	        |j
        |j                  d }~ww xY wd| _        | j         d {V }|t          ddd          	 t          j        |fi |S # t
          j        $ r%}t          |j	        |j
        |j                  d }~ww xY w)Nr  r   r   r  r  r   z+response cannot lead to unserializable JSONr  )rW   r  rf  r  r   r  s         rX   r   zAsyncResponse.json  s     $$$$$$ 	Q)*H"aPPP} 	(
 (	 	 	   dff  ) . 7G ;s>':':EEfEEE, G G G1!%FFFG !("i )*WY[]^___	?;}77777$ 	? 	? 	? *!%>>>	?s0   A= =B1 B,,B1C. .D"= DD"c                   K   | j         r|                                  d {V  | j        du r&| j        | j                                         d {V  t          | j        dd           }| |             d S d S )NFr  )r~  r  rn  rq  r  r  r  s     rX   r  zAsyncResponse.close  s      9 	!,,..       !U**tx/C(.."""""""""tx>>#LNNNNN $#rZ   )r[   r(  )r[   r'  )r[   r+  rW  r  )r  r8  r  r  r[   r0  r  )r  r8  r  r  r[   r2  )r  r8  r  r   r[   r4  )r  r8  r[   r0  r  )r  r8  r  r  r  r  r[   r0  )r  r8  r  r  r  r  r[   r2  )r  r8  r  r   r  r  r[   r4  r  r   r!  )rf   rg   rh   rX  r  ri   rw  r  r   r  r{  r  r"  r#  ri  r  r  rg  rf  rd  r   r  r$  r%  s   @rX   r'  r'  ]  sf        %%%%     N. 

 

 

 X

        < < < < </ / / /
 _FI1 1 1 1 _1 _ #/ / / / _/
 !09 9 9 9 9x !04 4 4 4 4l _ ),(+	1 1 1 1 _1 _ /
 ),/ / / / / _/ *$(,	" " " " "H       X D = = = X=<,? ,? ,? ,?\	 	 	 	 	 	 	 	rZ   r'  )r   
__future__r   r"  r  rr  encodings.idna	encodingsr  r   r  ImportErrorr   r"  TYPE_CHECKINGtyping_extensionsr   collections.abcr   r   r   r)  http.cookiejarr   ior   urllib.parser	   r
   r   charset_normalizerr   _typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   _vendor.kiss_headersr   r   ry   r   r   r{   r    r!   r"   r#   
exceptionsr$   r%   r&   r'   r(   r)   r*   r+   r,   r  r-   r  r}   r.   packages.urllib3r/   rA  r0   r1   r2   &packages.urllib3.contrib.webextensionsr3   r4   r5   -packages.urllib3.contrib.webextensions._asyncr6   r7   r8   packages.urllib3.exceptionsr9   r:   r;   r<   packages.urllib3.fieldsr=   packages.urllib3.filepostr>   r?   packages.urllib3.utilr@   status_codesrA   
structuresrB   utilsrC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   movedfoundothertemporary_redirectr  r  DEFAULT_REDIRECT_LIMITCONTENT_CHUNK_SIZEr  rP   rl   r   r[  r'  rj   rZ   rX   <module>rc     s    # " " " " "   
         	 *)))))) # # # # # # ' ' ' ' ' ' $ $ $ $ $ $ # # # # # # 8 8 8 8 8 8 8 8 8 8 ) ) ) ) ) )                                 4 3 3 3 3 3 3 3 0 0 0 0 0 0 0 0           	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 C B B B B B 4 4 4 4 4 4                          
         
         
              2 1 1 1 1 1 Q Q Q Q Q Q Q Q , , , , , ,       + + + + + +                       " 
K	K	K		   v v v v v v v v(s s s s s s s sl[	" [	" [	" [	" [	" [	" [	" [	"|h h h h h h h hVk k k k kH k k k k ks   # 	//