
     @g?                       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
mZ d dlmZmZ ddlmZmZmZmZ ddlmZmZmZmZmZmZmZmZ ddlmZmZm Z m!Z!m"Z"m#Z#m$Z$ dd	l%m&Z& dd
l'm(Z( ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=  G d dej>        e?e?f                   Z@ G d d          ZA G d d          ZB G d dej>        e?e?f                   ZCdS )    )annotationsN)Mapping)Cookie	CookieJar   )
ByteStreamUnattachedStreamencode_requestencode_response)SUPPORTED_DECODERSByteChunkerContentDecoderIdentityDecoderLineDecoderMultiDecoderTextChunkerTextDecoder)CookieConflictHTTPStatusErrorRequestNotReadResponseNotReadStreamClosedStreamConsumedrequest_context)(get_multipart_boundary_from_content_type)codes)AsyncByteStreamCookieTypesHeaderTypesQueryParamTypesRequestContentRequestDataRequestExtensionsRequestFilesResponseContentResponseExtensionsSyncByteStream)URL)is_known_encodingnormalize_header_keynormalize_header_valueobfuscate_sensitive_headersparse_content_type_charsetparse_header_linksc                      e Zd ZdZ	 	 d.d/d	Zed0d            Zej        d1d            Zed2d            Zd3dZ	d4dZ
d5dZd6dZd7d8dZd9d:d Zd7d;d!Zd<d"Zd=d#Zd>d$Zd?d%Zd@d&ZdAd(ZdBd*ZdCd,Zd0d-ZdS )DHeadersz9
    HTTP headers, as a case-insensitive multi-dict.
    NheadersHeaderTypes | Noneencoding
str | NonereturnNonec                $   |g | _         n}t          |t                    rt          |j                   | _         nNt          |t                    r&fd|                                D             | _         nfd|D             | _         | _        d S )Nc                |    g | ]8\  }}t          |d           t          |d          t          |          f9S F)lowerr3   Tr*   r+   .0kvr3   s      A/var/www/piapp/venv/lib/python3.11/site-packages/httpx/_models.py
<listcomp>z$Headers.__init__.<locals>.<listcomp>H   b        Aq	 )%(KKK($JJJ*1h77      c                |    g | ]8\  }}t          |d           t          |d          t          |          f9S r9   r;   r<   s      r@   rA   z$Headers.__init__.<locals>.<listcomp>Q   rB   rC   )_list
isinstancer0   listr   items	_encoding)selfr1   r3   s     `r@   __init__zHeaders.__init__>   s    
 ?DJJ)) 	gm,,DJJ)) 	    $MMOO  DJJ    $  DJ "rC   strc                    | j         ^dD ]T}| j        D ]A\  }}	 |                    |           |                    |           1# t          $ r Y  nw xY w|| _          nUd| _         | j         S )zn
        Header encoding is mandated as ascii, but we allow fallbacks to utf-8
        or iso-8859-1.
        N)asciiutf-8z
iso-8859-1)rI   rawdecodeUnicodeDecodeError)rJ   r3   keyvalues       r@   r3   zHeaders.encoding\   s     >!. . ."&( 
 
JC

8,,,X....-   
 &.DNE  ".~s   *A
AArT   c                    || _         d S N)rI   rJ   rT   s     r@   r3   zHeaders.encodingu   s    rC   list[tuple[bytes, bytes]]c                $    d | j         D             S )zH
        Returns a list of the raw header items, as byte pairs.
        c                    g | ]
\  }}}||fS  r[   )r=   raw_key_rT   s       r@   rA   zHeaders.raw.<locals>.<listcomp>~   s$    EEE%6Wa% EEErC   rE   rJ   s    r@   rP   zHeaders.rawy   s    
 FE$*EEEErC   typing.KeysView[str]c                N      fd j         D                                             S )Nc                N    i | ]!\  }}}|                     j                  d "S rV   rQ   r3   r=   r]   rS   rT   rJ   s       r@   
<dictcomp>z Headers.keys.<locals>.<dictcomp>   s/    PPPMAsE

4=))4PPPrC   )rE   keysr_   s   `r@   rf   zHeaders.keys   s+    PPPPTZPPPUUWWWrC   typing.ValuesView[str]c                    i }| j         D ]W\  }}}|                    | j                  }|                    | j                  }||v r||xx         d| z  cc<   R|||<   X|                                S )N, )rE   rQ   r3   valuesrJ   values_dictr]   rS   rT   str_key	str_values          r@   rj   zHeaders.values   s    &(!Z 	1 	1MAsEjj//GT]33I+%%G$$$(8Y(8(88$$$$'0G$$!!###rC   typing.ItemsView[str, str]c                    i }| j         D ]W\  }}}|                    | j                  }|                    | j                  }||v r||xx         d| z  cc<   R|||<   X|                                S )z
        Return `(key, value)` items of headers. Concatenate headers
        into a single comma separated value when a key occurs multiple times.
        ri   )rE   rQ   r3   rH   rk   s          r@   rH   zHeaders.items   s    
 ')!Z 	1 	1MAsEjj//GT]33I+%%G$$$(8Y(8(88$$$$'0G$$  """rC   list[tuple[str, str]]c                *      fd j         D             S )z
        Return a list of `(key, value)` pairs of headers. Allow multiple
        occurrences of the same key without concatenating into a single
        comma separated value.
        c                    g | ]:\  }}}|                     j                  |                     j                  f;S r[   rc   rd   s       r@   rA   z'Headers.multi_items.<locals>.<listcomp>   sP     
 
 
3 ZZ&&T](C(CD
 
 
rC   r^   r_   s   `r@   multi_itemszHeaders.multi_items   s0    
 
 
 
!%
 
 
 	
rC   rS   default
typing.Anyc                8    	 | |         S # t           $ r |cY S w xY w)z
        Return a header value. If multiple occurrences of the header occur
        then concatenate them together with commas.
        )KeyError)rJ   rS   ru   s      r@   getzHeaders.get   s5    
	9 	 	 	NNN	s   
 Fsplit_commasbool	list[str]c                    |                                                      j                   fd j        D             }|s|S g }|D ]4}|                    d |                    d          D                        5|S )z
        Return a list of all header values for a given key.
        If `split_commas=True` is passed, then any comma separated header
        values are split into multiple return strings.
        c                |    g | ]8\  }}}|                                 k    |                    j                  9S r[   )r:   rQ   r3   )r=   r]   item_key
item_valueget_header_keyrJ   s       r@   rA   z$Headers.get_list.<locals>.<listcomp>   sN     
 
 
'8Z~~>11 dm,,111rC   c                6    g | ]}|                                 S r[   )strip)r=   items     r@   rA   z$Headers.get_list.<locals>.<listcomp>   s      K K K$ K K KrC   ,)r:   encoder3   rE   extendsplit)rJ   rS   rz   rj   split_valuesrT   r   s   `     @r@   get_listzHeaders.get_list   s     ++DM::
 
 
 
 
+/:
 
 
  	M 	M 	ME K K%++c:J:J K K KLLLLrC   c                    t          |          }|                                D ]}|| v r|                     |           | j                            |j                   d S rV   )r0   rf   poprE   r   )rJ   r1   rS   s      r@   updatezHeaders.update   s]    '""<<>> 	 	Cd{{
'-(((((rC   c                .    t          | | j                  S )Nr3   )r0   r3   r_   s    r@   copyzHeaders.copy   s    tdm4444rC   c                     |                                                      j                   fd j        D             }|rd                    |          S t          |          )z
        Return a single header value.

        If there are multiple headers with the same key, then we concatenate
        them with commas. See: https://tools.ietf.org/html/rfc7230#section-3.2.2
        c                X    g | ]&\  }}}|k    |                     j                  'S r[   rc   )r=   r]   
header_keyheader_valuenormalized_keyrJ   s       r@   rA   z'Headers.__getitem__.<locals>.<listcomp>   sD     
 
 
+:|^++ ..+++rC   ri   )r:   r   r3   rE   joinrx   )rJ   rS   rH   r   s   `  @r@   __getitem__zHeaders.__getitem__   sz     ++DM::
 
 
 
 
/3z
 
 
  	$99U###smmrC   c                   |                     | j        pd          }|                     | j        pd          }|                                fdt          | j                  D             }t          |dd                   D ]
}| j        |= |r|d         }||f| j        |<   dS | j                            ||f           dS )zs
        Set the header `key` to `value`, removing any duplicate entries.
        Retains insertion order.
        rO   c                .    g | ]\  }\  }}}|k    |S r[   r[   )r=   idxr]   r   
lookup_keys       r@   rA   z'Headers.__setitem__.<locals>.<listcomp>   s9     
 
 
%%a1:%% %%%rC   r   Nr   )r   rI   r:   	enumeraterE   reversedappend)rJ   rS   rT   set_key	set_valuefound_indexesr   r   s          @r@   __setitem__zHeaders.__setitem__   s    
 **T^6w77LL!:7;;	]]__

 
 
 
)24:)>)>
 
 
 M!""-.. 	  	 C
3 	@"C&
I>DJsOOOJw
I>?????rC   c                    |                                                     | j                  fdt          | j                  D             }|st          |          t          |          D ]
}| j        |= dS )z*
        Remove the header `key`.
        c                R    g | ]#\  }\  }}}|                                 k    !|$S r[   )r:   )r=   r   r]   r   del_keys       r@   rA   z'Headers.__delitem__.<locals>.<listcomp>  sC     
 
 
%%a1~~7** ***rC   N)r:   r   r3   r   rE   rx   r   )rJ   rS   pop_indexesr   r   s       @r@   __delitem__zHeaders.__delitem__   s     ))++$$T]33
 
 
 
)24:)>)>
 
 
  	 3--K(( 	  	 C
3	  	 rC   c                    |                                                     | j                  }|d | j        D             v S )Nc                    g | ]\  }}}|	S r[   r[   )r=   r]   rS   s      r@   rA   z(Headers.__contains__.<locals>.<listcomp>  s    >>>iaac>>>rC   )r:   r   r3   rE   )rJ   rS   r   s      r@   __contains__zHeaders.__contains__  s;    YY[[''66
>>4:>>>>>rC   typing.Iterator[typing.Any]c                D    t          |                                           S rV   )iterrf   r_   s    r@   __iter__zHeaders.__iter__  s    DIIKK   rC   intc                *    t          | j                  S rV   )lenrE   r_   s    r@   __len__zHeaders.__len__  s    4:rC   otherc                    	 t          |          }n# t          $ r Y dS w xY wd | j        D             }d |j        D             }t          |          t          |          k    S )NFc                    g | ]
\  }}}||fS r[   r[   r=   r]   rS   rT   s       r@   rA   z"Headers.__eq__.<locals>.<listcomp>   s"    BBBmaec5\BBBrC   c                    g | ]
\  }}}||fS r[   r[   r   s       r@   rA   z"Headers.__eq__.<locals>.<listcomp>!  s"    LLL}q#usElLLLrC   )r0   
ValueErrorrE   sorted)rJ   r   other_headers	self_list
other_lists        r@   __eq__zHeaders.__eq__  s    	#ENNMM 	 	 	55	 CBtzBBB	LL8KLLL
i  F:$6$666s    
  c                .   | j         j        }d}| j        dk    r
d| j        }t          t	          |                                                     }t          |          }t          |          t          |          k    }|r
| d|| dS | d|| dS )N rN   z, encoding=())	__class____name__r3   rG   r,   rt   dictr   )rJ   
class_nameencoding_stras_listas_dictno_duplicate_keyss         r@   __repr__zHeaders.__repr__$  s    ^,
=G##:::L243C3C3E3EFFGGw--LLCLL8 	> ==7=l====99w9,9999rC   NN)r1   r2   r3   r4   r5   r6   r5   rL   rT   rL   r5   r6   )r5   rX   )r5   r`   )r5   rg   )r5   ro   )r5   rq   rV   )rS   rL   ru   rv   r5   rv   )F)rS   rL   rz   r{   r5   r|   )r1   r2   r5   r6   )r5   r0   )rS   rL   r5   rL   rS   rL   rT   rL   r5   r6   )rS   rL   r5   r6   )rS   rv   r5   r{   )r5   r   r5   r   )r   rv   r5   r{   )r   
__module____qualname____doc__rK   propertyr3   setterrP   rf   rj   rH   rt   ry   r   r   r   r   r   r   r   r   r   r   r   r[   rC   r@   r0   r0   9   s         '+#" " " " "<    X0 _   _ F F F XFX X X X	$ 	$ 	$ 	$# # # #	
 	
 	
 	
        ,) ) ) ) )5 5 5 5   (@ @ @ @0       $? ? ? ?! ! ! !   7 7 7 7: : : : : :rC   r0   c            
      t    e Zd Zdddddddddd	d)dZd*dZed+d             Zd+d!Zd+d"Zd,d$Z	d-d&Z
d.d(ZdS )/RequestN)	paramsr1   cookiescontentdatafilesjsonstream
extensionsmethodstr | bytesurl	URL | strr   QueryParamTypes | Noner1   r2   r   CookieTypes | Noner   RequestContent | Noner   RequestData | Noner   RequestFiles | Noner   typing.Any | Noner   'SyncByteStream | AsyncByteStream | Noner   RequestExtensions | Noner5   r6   c       	           t          |t                    r'|                    d                                          n|                                | _        t          |          | _        | | j                            |          | _        t          |          | _	        |i n|| _
        |r"t          |                              |            |
| j	                            d          }t          ||||	t          |r|                    | j	        j                  nd                     \  }}
|                     |           |
| _        t          |
t(                    r|                                  d S d S |
| _        d S )NrN   )r   zcontent-type)content_type)r   r   r   r   boundary)rF   bytesrQ   upperr   r(   r   copy_merge_paramsr0   r1   r   Cookiesset_cookie_headerry   r
   r   r   r3   _preparer   r   read)rJ   r   r   r   r1   r   r   r   r   r   r   r   r   s                r@   rK   zRequest.__init__5  s   " &%(( FMM'""((*** 	
 s88x111@@DHw'' * 2""
 	5G..t444>'+|'7'7'G'GL,A#"!4!4T\5J!K!K!K  
 
 
OGV MM'""" DK&*-- 		 " !DKKKrC   default_headersdict[str, str]c                   |                                 D ]B\  }}|                                dk    r
d| j        v r'| j                            ||           Cg }d| j        v }d| j        v pd| j        v }|s-| j        j        r!|                    d| j        j        f           |s| j        dv r|                    d           t          || j        j
        z             | _        d S )Ntransfer-encodingzContent-LengthHostzTransfer-Encodings   Host)POSTPUTPATCH)s   Content-Length   0)rH   r:   r1   
setdefaultr   hostr   netlocr   r0   rP   )rJ   r   rS   rT   auto_headershas_hosthas_content_lengths          r@   r   zRequest._prepareu  s   )//11 	0 	0JCyy{{1116F$,6V6VL##C////24T\),S0Ct|0S 	  	<DHM 	<$(/ :;;;! 	;dk5M&M&M 9:::|dl.>>??rC   r   c                L    t          | d          st                      | j        S N_content)hasattrr   r  r_   s    r@   r   zRequest.content  s(    tZ(( 	# """}rC   c                   t          | d          sst          | j        t          j                  sJ d                    | j                  | _        t          | j        t                    st          | j                  | _        | j        S )6
        Read and return the request content.
        r  rC   )r  rF   r   typingIterabler   r  r   r_   s    r@   r   zRequest.read  st     tZ(( 	8dk6?;;;;;HHT[11DMdk:66 8 )77}rC   c                :  K   t          | d          st          | j        t          j                  sJ d                    d | j        2              d{V           | _        t          | j        t                    st          | j                  | _        | j        S )r	  r  rC   c                "   K   g | 3 d {V }|
6 S rV   r[   r=   parts     r@   rA   z!Request.aread.<locals>.<listcomp>  s.      %I%I%I%I%I%I%I%ITd%I%I%I%I   N)r  rF   r   r
  AsyncIterabler   r  r   r_   s    r@   areadzRequest.aread  s       tZ(( 	8dk6+?@@@@@HH%I%IT[%I%I%I%I%I%I%I%I%IJJDMdk:66 8 )77}rC   rL   c                d    | j         j        }t          | j                  }d| d| j        d|dS )N<r   ri   z)>)r   r   rL   r   r   )rJ   r   r   s      r@   r   zRequest.__repr__  s<    ^,
$(mm::::::::::rC   dict[str, typing.Any]c                H    d | j                                         D             S )Nc                "    i | ]\  }}|d v	||S ))r   r   r[   r=   namerT   s      r@   re   z(Request.__getstate__.<locals>.<dictcomp>  s4     
 
 
e333 %333rC   __dict__rH   r_   s    r@   __getstate__zRequest.__getstate__  1    
 
#}2244
 
 
 	
rC   statec                    |                                 D ]\  }}t          | ||           i | _        t                      | _        d S rV   )rH   setattrr   r	   r   rJ   r  r  rT   s       r@   __setstate__zRequest.__setstate__  sJ     ;;== 	' 	'KD%D$&&&&&((rC   )r   r   r   r   r   r   r1   r2   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r5   r6   r   r   r5   r6   r5   r   r   r5   r  r  r  r5   r6   )r   r   r   rK   r   r   r   r   r  r   r  r"  r[   rC   r@   r   r   4  s         *.&*&*)-#'%)"&:>/3>! >! >! >! >! >!@@ @ @ @*    X
      ; ; ; ;

 
 
 
) ) ) ) ) )rC   r   c                     e Zd Zddddddddddd
d[dZd\dZed]d             Zej        d^d"            Zed_d$            Zej        d`d&            Zedad(            Z	edad)            Z
edbd+            Zedcd-            Zedad.            Zeddd/            Zej        ded0            Zeddd1            Zdfd3Zedgd5            Zedgd6            Zedgd7            Zedgd8            Zedgd9            Zedgd:            Zedgd;            Zdhd<Zdid>Zedjd@            ZedkdB            ZedldC            ZdadDZdmdFZdndHZdcdIZ dodpdMZ!dodqdOZ"drdPZ#dodpdQZ$dsdRZ%dcdSZ&	 dodtdUZ'	 dodudWZ(dvdXZ)	 dodtdYZ*dsdZZ+dS )wResponseNrO   )
r1   r   texthtmlr   r   requestr   historydefault_encodingstatus_coder   r1   r2   r   ResponseContent | Noner)  r4   r*  r   rv   r   r   r+  Request | Noner   ResponseExtensions | Noner,  list[Response] | Noner-  #str | typing.Callable[[bytes], str]r5   r6   c       
           || _         t          |          | _        || _        d | _        |	i n|	| _        |
g nt          |
          | _        d| _        d| _	        || _
        |[t          ||||          \  }}|                     |           || _        t          |t                    r|                                  n|| _        d| _        d S )NFr   )r.  r0   r1   _requestnext_requestr   rG   r,  	is_closedis_stream_consumedr-  r   r   r   rF   r   r   _num_bytes_downloaded)rJ   r.  r1   r   r)  r*  r   r   r+  r   r,  r-  s               r@   rK   zResponse.__init__  s     'w''(/ -14>4FbbJ$_rr$w--"' 0>-gtT4HHOGVMM'""" DK&*-- 		 !DK%&"""rC   r   r   c                    |                                 D ]B\  }}|                                dk    r
d| j        v r'| j                            ||           Cd S )Nr   zcontent-length)rH   r:   r1   r   )rJ   r   rS   rT   s       r@   r   zResponse._prepare  sj    )//11 	0 	0JCyy{{1116F$,6V6VL##C////		0 	0rC   datetime.timedeltac                N    t          | d          st          d          | j        S )ze
        Returns the time taken for the complete request/response
        cycle to complete.
        _elapsedzK'.elapsed' may only be accessed after the response has been read or closed.)r  RuntimeErrorr=  r_   s    r@   elapsedzResponse.elapsed  s7     tZ(( 	+   }rC   r?  c                    || _         d S rV   )r=  )rJ   r?  s     r@   r?  zResponse.elapsed  s    rC   r   c                <    | j         t          d          | j         S )zR
        Returns the request instance associated to the current response.
        Nz7The request instance has not been set on this response.)r5  r>  r_   s    r@   r+  zResponse.request  s+    
 = I   }rC   rT   c                    || _         d S rV   )r5  rW   s     r@   r+  zResponse.request  s    rC   rL   c                n    	 | j         d         }|                    dd          S # t          $ r Y dS w xY w)Nhttp_versionrN   ignoreerrorszHTTP/1.1)r   rQ   rx   )rJ   rD  s     r@   rD  zResponse.http_version  sS    	A"&/."AL  &&wx&@@@  	 	 	::	s   & 
44c                    	 | j         d         }|                    dd          S # t          $ r t          j        | j                  cY S w xY w)Nreason_phraserN   rE  rF  )r   rQ   rx   r   get_reason_phraser.  )rJ   rI  s     r@   rI  zResponse.reason_phrase'  sf    	B#'??#CM !'''AAA  	= 	= 	=*4+;<<<<<	=s   & #AAr(   c                    | j         j        S )zA
        Returns the URL for which the request was made.
        )r+  r   r_   s    r@   r   zResponse.url0  s    
 |rC   r   c                L    t          | d          st                      | j        S r  )r  r   r  r_   s    r@   r   zResponse.content7  s(    tZ(( 	$!###}rC   c                   t          | d          sn| j        }|sd| _        n]t          | j        pd          }d                    |                    | j                  |                                g          | _        | j        S )N_textr   rO   r   )r  r   rN  r   r3   r   rQ   flush)rJ   r   decoders      r@   r)  zResponse.text=  s{    tW%% 	VlG V

%t}/GHHHWWgnnT\&B&BGMMOO%TUU
zrC   c                
   t          | d          sm| j        }|t          |          sLt          | j        t
                    r| j        }n*t          | d          r|                     | j                  }|pd| _        | j        S )a  
        Return an encoding to use for decoding the byte content into text.
        The priority for determining this is given by...

        * `.encoding = <>` has been set explicitly.
        * The encoding as specified by the charset parameter in the Content-Type header.
        * The encoding as determined by `default_encoding`, which may either be
          a string like "utf-8" indicating the encoding to use, or may be a callable
          which enables charset autodetection.
        rI   Nr  rO   )r  charset_encodingr)   rF   r-  rL   r  rI   )rJ   r3   s     r@   r3   zResponse.encodingH  s     t[)) 	1,H'8'B'Bd3S99 D#4HHT:.. D#44T]CCH%0DN~rC   c                R    t          | d          rt          d          || _        dS )z
        Set the encoding to use for decoding the byte content into text.

        If the `text` attribute has been accessed, attempting to set the
        encoding will throw a ValueError.
        rN  z?Setting encoding after `text` has been accessed is not allowed.N)r  r   rI   rW   s     r@   r3   zResponse.encoding^  s8     4!! 	Q   rC   c                \    | j                             d          }|dS t          |          S )zO
        Return the encoding, as specified by the Content-Type header.
        zContent-TypeN)r1   ry   r-   )rJ   r   s     r@   rR  zResponse.charset_encodingl  s2    
 |''774),777rC   r   c                   t          | d          sg }| j                            dd          }|D ]c}|                                                                }	 t
          |         }|                     |                       T# t          $ r Y `w xY wt          |          dk    r|d         | _	        n<t          |          dk    rt          |          | _	        nt                      | _	        | j	        S )z
        Returns a decoder instance which can be used to decode the raw byte
        content, depending on the Content-Encoding used in the response.
        _decoderzcontent-encodingT)rz   r   r   )children)r  r1   r   r   r:   r   r   rx   r   rV  r   r   )rJ   decodersrj   rT   decoder_clss        r@   _get_content_decoderzResponse._get_content_decoderw  s   
 tZ(( 	2-/H\**+=D*QQF  ++--"4U";KOOKKMM2222   H 8}}!! (X"" ,h ? ? ? / 1 1}s   *B
BBr{   c                4    t          j        | j                  S )zU
        A property which is `True` for 1xx status codes, `False` otherwise.
        )r   is_informationalr.  r_   s    r@   r\  zResponse.is_informational  s    
 %d&6777rC   c                4    t          j        | j                  S )zU
        A property which is `True` for 2xx status codes, `False` otherwise.
        )r   
is_successr.  r_   s    r@   r^  zResponse.is_success  s    
  0111rC   c                4    t          j        | j                  S )a  
        A property which is `True` for 3xx status codes, `False` otherwise.

        Note that not all responses with a 3xx status code indicate a URL redirect.

        Use `response.has_redirect_location` to determine responses with a properly
        formed URL redirection.
        )r   is_redirectr.  r_   s    r@   r`  zResponse.is_redirect  s      !1222rC   c                4    t          j        | j                  S )zU
        A property which is `True` for 4xx status codes, `False` otherwise.
        )r   is_client_errorr.  r_   s    r@   rb  zResponse.is_client_error      
 $T%5666rC   c                4    t          j        | j                  S )zU
        A property which is `True` for 5xx status codes, `False` otherwise.
        )r   is_server_errorr.  r_   s    r@   re  zResponse.is_server_error  rc  rC   c                4    t          j        | j                  S )z]
        A property which is `True` for 4xx and 5xx status codes, `False` otherwise.
        )r   is_errorr.  r_   s    r@   rg  zResponse.is_error  s    
 ~d.///rC   c                    | j         t          j        t          j        t          j        t          j        t          j        fv od| j        v S )zs
        Returns True for 3xx responses with a properly formed URL redirection,
        `False` otherwise.
        Location)r.  r   MOVED_PERMANENTLYFOUND	SEE_OTHERTEMPORARY_REDIRECTPERMANENT_REDIRECTr1   r_   s    r@   has_redirect_locationzResponse.has_redirect_location  sH      '(( + dl*	
rC   c                    | j         }|t          d          | j        r| S | j        rd}nd}| j        dz  }dddd	d
}|                    |d          }|                    | |          }t          |||           )z>
        Raise the `HTTPStatusError` if one occurred.
        NzYCannot call `raise_for_status` as the request instance has not been set on this response.z{error_type} '{0.status_code} {0.reason_phrase}' for url '{0.url}'
Redirect location: '{0.headers[location]}'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/{0.status_code}z{error_type} '{0.status_code} {0.reason_phrase}' for url '{0.url}'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/{0.status_code}d   zInformational responsezRedirect responsezClient errorzServer error)r            zInvalid status code)
error_type)r+  response)r5  r>  r^  ro  r.  ry   formatr   )rJ   r+  messagestatus_classerror_typesru  s         r@   raise_for_statuszResponse.raise_for_status  s     -?>  
 ? 	K% 
	w Gw 
 '3.'"	
 
 !__\3HII
..*.==gwFFFFrC   kwargsc                0    t          j        | j        fi |S rV   )jsonlibloadsr   )rJ   r|  s     r@   r   zResponse.json  s    }T\44V444rC   r   c                    t          | d          s-t                      | _        | j                            |            | j        S )N_cookies)r  r   r  extract_cookiesr_   s    r@   r   zResponse.cookies  s=    tZ(( 	0#IIDMM))$///}rC    dict[str | None, dict[str, str]]c                p    | j                             d          }|i S d t          |          D             S )zI
        Returns the parsed header links of the response, if any
        linkNc                d    i | ]-}|                     d           p|                     d          |.S )relr   )ry   )r=   r  s     r@   re   z"Response.links.<locals>.<dictcomp>  sC     
 
 
 XXe__/$
 
 
rC   )r1   ry   r.   )rJ   headers     r@   linkszResponse.links  sL    
 !!&))>I
 
*622
 
 
 	
rC   c                    | j         S rV   )r9  r_   s    r@   num_bytes_downloadedzResponse.num_bytes_downloaded  s    ))rC   c                (    d| j          d| j         dS )Nz<Response [ ]>)r.  rI  r_   s    r@   r   zResponse.__repr__  s!    FT-FF0BFFFFrC   r  c                H    d | j                                         D             S )Nc                "    i | ]\  }}|d v	||S ))r   r   r7  rV  r[   r  s      r@   re   z)Response.__getstate__.<locals>.<dictcomp>  s4     
 
 
eLLL %LLLrC   r  r_   s    r@   r  zResponse.__getstate__  r  rC   r  c                    |                                 D ]\  }}t          | ||           d| _        i | _        t	                      | _        d S )NT)rH   r   r7  r   r	   r   r!  s       r@   r"  zResponse.__setstate__!  sQ     ;;== 	' 	'KD%D$&&&&&((rC   c                    t          | d          s,d                    |                                           | _        | j        S )7
        Read and return the response content.
        r  rC   )r  r   
iter_bytesr  r_   s    r@   r   zResponse.read(  s;     tZ(( 	8HHT__%6%677DM}rC   
chunk_size
int | Nonetyping.Iterator[bytes]c              #    K   t          | d          rb|t          | j                  n|}t          dt          | j                  t	          |d                    D ]}| j        |||z            V  dS |                                 }t          |          }t          | j                  5  | 	                                D ]3}|
                    |          }|
                    |          D ]}|V  4|                                }|
                    |          D ]}|V  |                                D ]}|V  	 ddd           dS # 1 swxY w Y   dS z
        A byte-iterator over the decoded response content.
        This allows us to handle gzip, deflate, and brotli encoded responses.
        r  Nr   r   r  r+  )r  r   r  rangemaxrZ  r   r   r5  iter_rawrQ   rO  rJ   r  irP  chunker	raw_bytesdecodedchunks           r@   r  zResponse.iter_bytes0  s     
 4$$ 	 /9/AT]+++zJ1c$-00#j!2D2DEE 8 8mAJ$6777778 8 //11G!Z888G 777 	  	 !% $ $I%nnY77G!(!8!8 $ $#$!--//$^^G44    EKKKK$]]__    EKKKK 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   .BEEEtyping.Iterator[str]c              #    K   t          | j        pd          }t          |          }t          | j                  5  |                                 D ]3}|                    |          }|                    |          D ]}|V  4|                                }|                    |          D ]}|V  |                                D ]}|V  	 ddd           dS # 1 swxY w Y   dS z
        A str-iterator over the decoded response content
        that handles both gzip, deflate, etc but also detects the content's
        string encoding.
        rO   r   r  r  N)r   r3   r   r   r5  r  rQ   rO  rJ   r  rP  r  byte_contenttext_contentr  s          r@   	iter_textzResponse.iter_textG  sU      t}'?@@@444T]333 		 		 $ 1 1    &~~l;;$^^L99    EKKKK "==??L 55     		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		s   BC!!C%(C%c              #     K   t                      }t          | j                  5  |                                 D ]}|                    |          D ]}|V  |                                D ]}|V  	 d d d            d S # 1 swxY w Y   d S Nr  )r   r   r5  r  rQ   rO  rJ   rP  r)  lines       r@   
iter_lineszResponse.iter_linesZ  s      --T]333 	 	((  #NN400  DJJJJ  



		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   ABB
Bc              #  ,  K   | j         rt                      | j        rt                      t	          | j        t                    st          d          d| _         d| _        t          |          }t          | j                  5  | j        D ];}| xj        t          |          z  c_        |                    |          D ]}|V  <	 ddd           n# 1 swxY w Y   |                                D ]}|V  |                                  dS )@
        A byte-iterator over the raw response content.
        z5Attempted to call a sync iterator on an async stream.Tr   r  r  N)r8  r   r7  r   rF   r   r'   r>  r9  r   r   r5  r   rQ   rO  closerJ   r  r  raw_stream_bytesr  s        r@   r  zResponse.iter_rawc  st      " 	# """> 	!.. $+~66 	XVWWW"&%&"444T]333 	  	 $(K     **c2B.C.CC**$^^,<==    EKKKK  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  ]]__ 	 	EKKKK

s   	ACC!Cc                   t          | j        t                    st          d          | j        sPd| _        t          | j                  5  | j                                         ddd           dS # 1 swxY w Y   dS dS )
        Close the response and release the connection.
        Automatically called if the response body is read to completion.
        z3Attempted to call an sync close on an async stream.Tr  N)rF   r   r'   r>  r7  r   r5  r  r_   s    r@   r  zResponse.close}  s    
 $+~66 	VTUUU~ 	$!DN 777 $ $!!###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $	$ 	$s   A44A8;A8c                   K   t          | d          s<d                    d |                                 2              d{V           | _        | j        S )r  r  rC   c                "   K   g | 3 d {V }|
6 S rV   r[   r  s     r@   rA   z"Response.aread.<locals>.<listcomp>  s.      %P%P%P%P%P%P%P%PTd%P%P%P%Pr  N)r  r   aiter_bytesr  r_   s    r@   r  zResponse.aread  sc       tZ(( 	RHH%P%PT=M=M=O=O%P%P%P%P%P%P%P%P%PQQDM}rC   typing.AsyncIterator[bytes]c                 K   t          | d          rc|t          | j                  n|}t          dt          | j                  t	          |d                    D ]}| j        |||z            W V  dS |                                 }t          |          }t          | j                  5  | 	                                2 3 d{V }|
                    |          }|
                    |          D ]}|W V  :6 |                                }|
                    |          D ]}|W V  |                                D ]}|W V  	 ddd           dS # 1 swxY w Y   dS r  )r  r   r  r  r  rZ  r   r   r5  	aiter_rawrQ   rO  r  s           r@   r  zResponse.aiter_bytes  s      4$$ 	 /9/AT]+++zJ1c$-00#j!2D2DEE 8 8mAJ$67777778 8 //11G!Z888G 777 	  	 '+~~'7'7 $ $ $ $ $ $ $)%nnY77G!(!8!8 $ $#$ (8 "--//$^^G44    EKKKKK$]]__    EKKKKK 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   /EC>
BEE!Etyping.AsyncIterator[str]c                 K   t          | j        pd          }t          |          }t          | j                  5  |                                 2 3 d{V }|                    |          }|                    |          D ]}|W V  :6 |                                }|                    |          D ]}|W V  |                                D ]}|W V  	 ddd           dS # 1 swxY w Y   dS r  )r   r3   r   r   r5  r  rQ   rO  r  s          r@   
aiter_textzResponse.aiter_text  s}      t}'?@@@444T]333 		 		&*&6&6&8&8              l&~~l;;$^^L99    EKKKKK  '9 #==??L 55     		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		s   C*BBC**C.1C.c               0  K   t                      }t          | j                  5  |                                 2 3 d {V }|                    |          D ]}|W V  %6 |                                D ]}|W V  	 d d d            d S # 1 swxY w Y   d S r  )r   r   r5  r  rQ   rO  r  s       r@   aiter_lineszResponse.aiter_lines  s     --T]333 	 	"oo//       d#NN400  DJJJJJ 0    




		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   BA <BBBc               H  K   | j         rt                      | j        rt                      t	          | j        t                    st          d          d| _         d| _        t          |          }t          | j                  5  | j        2 3 d{V }| xj        t          |          z  c_        |                    |          D ]}|W V  B6 	 ddd           n# 1 swxY w Y   |                                D ]}|W V  |                                  d{V  dS )r  z6Attempted to call an async iterator on an sync stream.Tr   r  r  N)r8  r   r7  r   rF   r   r   r>  r9  r   r   r5  r   rQ   rO  acloser  s        r@   r  zResponse.aiter_raw  s      " 	# """> 	!.. $+77 	YWXXX"&%&"444T]333 	  	 *.+              &**c2B.C.CC**$^^,<==    EKKKKK  +6+	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  ]]__ 	 	EKKKKKkkmms   	C!C=C!!C%(C%c                  K   t          | j        t                    st          d          | j        sVd| _        t          | j                  5  | j                                         d{V  ddd           dS # 1 swxY w Y   dS dS )r  z3Attempted to call an async close on an sync stream.Tr  N)rF   r   r   r>  r7  r   r5  r  r_   s    r@   r  zResponse.aclose  s      
 $+77 	VTUUU~ 	+!DN 777 + +k((*********+ + + + + + + + + + + + + + + + + +	+ 	+s    A<<B B )r.  r   r1   r2   r   r/  r)  r4   r*  r4   r   rv   r   r   r+  r0  r   r1  r,  r2  r-  r3  r5   r6   r#  )r5   r;  )r?  r;  r5   r6   )r5   r   )rT   r   r5   r6   r   )r5   r(   r$  )r5   r4   r   )r5   r   r5   r{   )r5   r(  )r|  rv   r5   rv   )r5   r   )r5   r  r   r%  r&  rV   )r  r  r5   r  )r  r  r5   r  r5   r  )r5   r6   )r  r  r5   r  )r  r  r5   r  )r5   r  ),r   r   r   rK   r   r   r?  r   r+  rD  rI  r   r   r)  r3   rR  rZ  r\  r^  r`  rb  re  rg  ro  r{  r   r   r  r  r   r  r"  r   r  r  r  r  r  r  r  r  r  r  r  r[   rC   r@   r(  r(    s       
 '+*.:>"&04)-@G5' 5' 5' 5' 5' 5'n0 0 0 0 
 
 
 X
 ^      ^     X ^   ^ A A A XA B B B XB       X     X
    X    X* _   _ 8 8 8 X8   2 8 8 8 X8 2 2 2 X2 	3 	3 	3 X	3 7 7 7 X7 7 7 7 X7 0 0 0 X0 
 
 
 X
,#G #G #G #GJ5 5 5 5    X 
 
 
 X
 * * * X*G G G G
 
 
 
) ) ) )            .    &       4$ $ $ $    (,         4 (,    *    (,    8+ + + + + +rC   r(  c                      e Zd ZdZd*d+dZd,d
Zd-dZd.d/dZ	 	 	 d0d1dZ	 	 d2d3dZ	d2d4dZ
d*d+dZd5dZd6dZd7dZd8d Zd9d"Zd:d$Zd;d%Z G d& d'ej        j                  Z G d( d)          ZdS )<r   z-
    HTTP Cookies, as a mutable mapping.
    Nr   r   r5   r6   c                &   |t          |t                    r\t                      | _        t          |t                    r0|                                D ]\  }}|                     ||           d S d S t          |t                    r3t                      | _        |D ]\  }}|                     ||           d S t          |t                    r9t                      | _        |j        D ]}| j                            |           d S || _        d S rV   )	rF   r   r   jarrH   setrG   r   
set_cookie)rJ   r   rS   rT   cookies        r@   rK   zCookies.__init__  s'   ?j$77? {{DH'4(( )")--// ) )JCHHS%(((() )) )&& 		 {{DH% % %
Ue$$$$% %)) 	 {{DH!+ , ,##F++++, , DHHHrC   rv  r(  c                    |                      |          }|                     |j                  }| j                            ||           dS )zO
        Loads any cookies based on the response `Set-Cookie` headers.
        N)_CookieCompatResponse_CookieCompatRequestr+  r  r  )rJ   rv  urllib_responseurllib_requests       r@   r  zCookies.extract_cookies	  sK     44X>>2283CDD  .AAAAArC   r+  r   c                d    |                      |          }| j                            |           dS )zM
        Sets an appropriate 'Cookie:' HTTP header on the `Request`.
        N)r  r  add_cookie_header)rJ   r+  r  s      r@   r   zCookies.set_cookie_header  s3     227;;"">22222rC   r   /r  rL   rT   domainpathc                   i ddd|d|ddddd	|d
t          |          d|                    d          d|dt          |          dddddddddddddidd}t          di |}| j                            |           dS )zU
        Set a cookie value by name. May optionally include domain and path.
        versionr   r  rT   portNport_specifiedFr  domain_specifieddomain_initial_dot.r  path_specifiedsecureexpiresdiscardTcommentcomment_urlrestHttpOnlyrfc2109r[   )r{   
startswithr   r  r  )rJ   r  rT   r  r  r|  r  s          r@   r  zCookies.set  s!   
q
D
 U
 D	

 e
 f
 V
 !&"3"3C"8"8
 D
 d4jj
 e
 t
 t
 t
 4
  Z&!
" u#
& !!&!!F#####rC   ru   r4   c                    d}| j         D ]D}|j        |k    r7||j        |k    r*||j        |k    r|d| }t	          |          |j        }E||S |S )z
        Get a cookie by name. May optionally include domain and path
        in order to specify exactly which cookie to retrieve.
        Nz!Multiple cookies exist with name=)r  r  r  r  r   rT   )rJ   r  ru   r  r  rT   r  rx  s           r@   ry   zCookies.get3  s     h 	- 	-F{d"">V]f%<%<|v{d':': ,&P$&P&PG"0"9"99 &=NrC   c                    | j                                       S fd| j         D             }|D ]-}| j                             |j        |j        |j                   .dS )z
        Delete a cookie by name. May optionally include domain and path
        in order to specify exactly which cookie to delete.
        Nc                ^    g | ])}|j         k    r|j        k    r|j        k    '|*S rV   )r  r  r  )r=   r  r  r  r  s     r@   rA   z"Cookies.delete.<locals>.<listcomp>Y  sT     
 
 
{d""6=F#:#:!4!4	  "5!4!4rC   )r  clearr  r  r  )rJ   r  r  r  remover  s    ```  r@   deletezCookies.deleteL  s     $"28>>&$555
 
 
 
 
 
(
 
 
  	D 	DFHNN6=&+v{CCCC	D 	DrC   c                    g }||                     |           ||J |                     |            | j        j        |  dS )z
        Delete all cookies. Optionally include a domain and path in
        order to only delete a subset of all the cookies.
        N)r   r  r  )rJ   r  r  argss       r@   r  zCookies.cleard  s\    
 KK%%%KKrC   c                l    t          |          }|j        D ]}| j                            |           d S rV   )r   r  r  )rJ   r   r  s      r@   r   zCookies.updateq  sC    '""k 	( 	(FH''''	( 	(rC   c                .    |                      ||          S rV   )r  rJ   r  rT   s      r@   r   zCookies.__setitem__v  s    xxe$$$rC   c                R    |                      |          }|t          |          |S rV   )ry   rx   r  s      r@   r   zCookies.__getitem__y  s'    =4.. rC   c                ,    |                      |          S rV   )r  )rJ   r  s     r@   r   zCookies.__delitem__  s    {{4   rC   r   c                *    t          | j                  S rV   )r   r  r_   s    r@   r   zCookies.__len__  s    48}}rC   r  c                $    d | j         D             S )Nc              3  $   K   | ]}|j         V  d S rV   )r  r=   r  s     r@   	<genexpr>z#Cookies.__iter__.<locals>.<genexpr>  s$      33333333rC   r  r_   s    r@   r   zCookies.__iter__  s    33$(3333rC   r{   c                    | j         D ]} dS dS )NTFr  )rJ   r]   s     r@   __bool__zCookies.__bool__  s     	 	A44urC   c                V    d                     d | j        D                       }d| dS )Nri   c           	     D    g | ]}d |j          d|j         d|j         dS )z<Cookie =z for z />)r  rT   r  r  s     r@   rA   z$Cookies.__repr__.<locals>.<listcomp>  sJ        O6;NNNNFMNNN  rC   z	<Cookies[r  )r   r  )rJ   cookies_reprs     r@   r   zCookies.__repr__  sF    yy "h  
 
 ,<++++rC   c                  0     e Zd ZdZd fdZd fd
Z xZS )Cookies._CookieCompatRequest
        Wraps a `Request` instance up in a compatibility interface suitable
        for use with `CookieJar` operations.
        r+  r   r5   r6   c                    t                                          t          |j                  t	          |j                  |j                   || _        d S )N)r   r1   r   )superrK   rL   r   r   r1   r   r+  )rJ   r+  r   s     r@   rK   z%Cookies._CookieCompatRequest.__init__  sP    GG$$W_--~    
 #DLLLrC   rS   rL   rT   c                j    t                                          ||           || j        j        |<   d S rV   )r  add_unredirected_headerr+  r1   )rJ   rS   rT   r   s      r@   r  z4Cookies._CookieCompatRequest.add_unredirected_header  s2    GG++C777(-DL %%%rC   r+  r   r5   r6   r   )r   r   r   r   rK   r  __classcell__)r   s   @r@   r  r    se        	 	
	# 	# 	# 	# 	# 	#	. 	. 	. 	. 	. 	. 	. 	. 	. 	.rC   r  c                  "    e Zd ZdZd
dZddZd	S )Cookies._CookieCompatResponser  rv  r(  r5   r6   c                    || _         d S rV   )rv  )rJ   rv  s     r@   rK   z&Cookies._CookieCompatResponse.__init__  s    $DMMMrC   email.message.Messagec                    t           j                                        }| j        j                                        D ]
\  }}|||<   |S rV   )emailrx  Messagerv  r1   rt   )rJ   inforS   rT   s       r@   r  z"Cookies._CookieCompatResponse.info  sK    =((**D"m3??AA " "
U "S		KrC   Nrv  r(  r5   r6   )r5   r  )r   r   r   r   rK   r  r[   rC   r@   r  r    sF        	 	
	% 	% 	% 	%	 	 	 	 	 	rC   r  rV   )r   r   r5   r6   r  r	  )r   r  )
r  rL   rT   rL   r  rL   r  rL   r5   r6   )NNN)
r  rL   ru   r4   r  r4   r  r4   r5   r4   r   )r  rL   r  r4   r  r4   r5   r6   )r  r4   r  r4   r5   r6   )r  rL   rT   rL   r5   r6   )r  rL   r5   rL   )r  rL   r5   r6   r   r  r  r   )r   r   r   r   rK   r  r   r  ry   r  r  r   r   r   r   r   r   r  r   urllibr+  r   r  r  r[   rC   r@   r   r     s            "B B B B3 3 3 3$ $ $ $ $: #!    8 "	D D D D D0    ( ( ( ( (
% % % %   ! ! ! !   4 4 4 4   
, , , ,. . . . .v~5 . . .$         rC   r   )D
__future__r   datetimeemail.messager  r   r~  r
  urllib.requestr  collections.abcr   http.cookiejarr   r   r  r   r	   r
   r   	_decodersr   r   r   r   r   r   r   r   _exceptionsr   r   r   r   r   r   r   
_multipartr   _status_codesr   _typesr   r   r   r    r!   r"   r#   r$   r%   r&   r'   _urlsr(   _utilsr)   r*   r+   r,   r-   r.   MutableMappingrL   r0   r   r(  r   r[   rC   r@   <module>r#     sQ   " " " " " "               # # # # # # , , , , , , , , S S S S S S S S S S S S	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	                  A @ @ @ @ @                                                          x: x: x: x: x:f#CH- x: x: x:vH) H) H) H) H) H) H) H)Vq+ q+ q+ q+ q+ q+ q+ q+hF F F F Ff#CH- F F F F FrC   