o
    Þ­j„¥  ã                   @  sˆ  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¢Z>G dd„ dej?e@e@f ƒZAG dd„ dƒZBG dd„ dƒZCG dd„ dej?e@e@f ƒZDd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_links)ÚCookiesÚHeadersÚRequestÚResponsec                   @  sò   e Zd ZdZ		dAdBd	d
„ZedCdd„ƒZejdDdd„ƒZedEdd„ƒZdFdd„Z	dGdd„Z
dHdd„ZdIdd„ZdJdKd"d#„ZdLdMd(d)„ZdJdNd*d+„ZdOd,d-„ZdPd.d/„ZdQd0d1„ZdRd2d3„ZdSd4d5„ZdTd7d8„ZdUd:d;„ZdVd=d>„ZdCd?d@„ZdS )Wr/   z9
    HTTP headers, as a case-insensitive multi-dict.
    NÚheadersúHeaderTypes | NoneÚencodingú
str | NoneÚreturnÚNonec                   sj   |d u rg | _ n(t|tƒrt|j ƒ| _ nt|tƒr&‡ fdd„| ¡ D ƒ| _ n
‡ fdd„|D ƒ| _ ˆ | _d S )Nc                   ó4   g | ]\}}t |d ˆ d�t |dˆ d�t|ˆ ƒf‘qS ©F)Úlowerr4   T©r)   r*   ©Ú.0ÚkÚv©r4   © úJ/var/www/html/CropPilot/venv/lib/python3.10/site-packages/httpx/_models.pyÚ
<listcomp>J   ó    üýÿz$Headers.__init__.<locals>.<listcomp>c                   r8   r9   r;   r<   r@   rA   rB   rC   S   rD   )Ú_listÚ
isinstancer/   Úlistr   ÚitemsÚ	_encoding)Úselfr2   r4   rA   r@   rB   Ú__init__@   s   



ú
	ú
	zHeaders.__init__Ústrc              
   C  sj   | j du r2dD ]'}| jD ]\}}z| |¡ | |¡ W q ty&   Y  nw || _  | j S qd| _ | 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   r4   ÚkeyÚvaluerA   rA   rB   r4   ^   s   

ÿö	zHeaders.encodingrS   c                 C  ó
   || _ d S ©N)rI   ©rJ   rS   rA   rA   rB   r4   w   ó   
úlist[tuple[bytes, bytes]]c                 C  ó   dd„ | j D ƒS )zH
        Returns a list of the raw header items, as byte pairs.
        c                 S  s   g | ]	\}}}||f‘qS rA   rA   )r=   Úraw_keyÚ_rS   rA   rA   rB   rC   €   ó    zHeaders.raw.<locals>.<listcomp>©rE   ©rJ   rA   rA   rB   rO   {   s   zHeaders.rawútyping.KeysView[str]c                   s   ‡ fdd„ˆ j D ƒ ¡ S )Nc                   s    i | ]\}}}|  ˆ j¡d “qS rU   ©rP   r4   ©r=   r[   rR   rS   r^   rA   rB   Ú
<dictcomp>ƒ   s     z Headers.keys.<locals>.<dictcomp>)rE   Úkeysr^   rA   r^   rB   rc   ‚   s   zHeaders.keysútyping.ValuesView[str]c                 C  ó^   i }| j D ]%\}}}| | j¡}| | j¡}||v r&||  d|› �7  < q|||< q| ¡ S )Nú, )rE   rP   r4   Úvalues©rJ   Úvalues_dictr[   rR   rS   Ústr_keyÚ	str_valuerA   rA   rB   rg   …   s   
zHeaders.valuesútyping.ItemsView[str, str]c                 C  re   )z›
        Return `(key, value)` items of headers. Concatenate headers
        into a single comma separated value when a key occurs multiple times.
        rf   )rE   rP   r4   rH   rh   rA   rA   rB   rH   �   s   
zHeaders.itemsúlist[tuple[str, str]]c                   s   ‡ fd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                   s*   g | ]\}}}|  ˆ j¡|  ˆ j¡f‘qS rA   r`   ra   r^   rA   rB   rC   ¥   s    ÿÿz'Headers.multi_items.<locals>.<listcomp>r]   r^   rA   r^   rB   Úmulti_itemsŸ   s   
þzHeaders.multi_itemsrR   Údefaultú
typing.Anyc                 C  s"   z| | W S  t y   | Y S w )zˆ
        Return a header value. If multiple occurrences of the header occur
        then concatenate them together with commas.
        )ÚKeyError)rJ   rR   ro   rA   rA   rB   Úgetª   s
   
ÿzHeaders.getFÚsplit_commasÚboolú	list[str]c                   sZ   |  ¡  ˆj¡‰ ‡ ‡fdd„ˆjD ƒ}|s|S g }|D ]}| dd„ | d¡D ƒ¡ q|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                   s*   g | ]\}}}|  ¡ ˆ kr| ˆj¡‘qS rA   )r:   rP   r4   )r=   r[   Úitem_keyÚ
item_value©Úget_header_keyrJ   rA   rB   rC   ¼   s
    
þz$Headers.get_list.<locals>.<listcomp>c                 S  s   g | ]}|  ¡ ‘qS rA   )Ústrip)r=   ÚitemrA   rA   rB   rC   Ç   s    ú,)r:   Úencoder4   rE   ÚextendÚsplit)rJ   rR   rs   rg   Úsplit_valuesrS   rA   rx   rB   Úget_list´   s   þzHeaders.get_listc                 C  s:   t |ƒ}| ¡ D ]}|| v r|  |¡ q| j |j¡ d S rU   )r/   rc   ÚpoprE   r~   )rJ   r2   rR   rA   rA   rB   ÚupdateÊ   s   
€zHeaders.updatec                 C  s   t | | jd�S )Nr@   )r/   r4   r^   rA   rA   rB   ÚcopyÑ   s   zHeaders.copyc                   s<   |  ¡  ˆj¡‰ ‡ ‡fd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                   s&   g | ]\}}}|ˆ kr|  ˆj¡‘qS rA   r`   )r=   r[   Ú
header_keyÚheader_value©Únormalized_keyrJ   rA   rB   rC   Ý   s
    
þz'Headers.__getitem__.<locals>.<listcomp>rf   )r:   r}   r4   rE   Újoinrq   )rJ   rR   rH   rA   r‡   rB   Ú__getitem__Ô   s   þ
zHeaders.__getitem__c                   s”   |  | jpd¡}|  | jpd¡}| ¡ ‰ ‡ fdd„t| jƒD ƒ}t|dd… ƒD ]}| j|= q(|r?|d }|ˆ |f| j|< dS | j |ˆ |f¡ dS )zs
        Set the header `key` to `value`, removing any duplicate entries.
        Retains insertion order.
        rN   c                   s"   g | ]\}\}}}|ˆ kr|‘qS rA   rA   ©r=   Úidxr[   rv   ©Ú
lookup_keyrA   rB   rC   ñ   s
    þz'Headers.__setitem__.<locals>.<listcomp>r   Nr   )r}   rI   r:   Ú	enumeraterE   ÚreversedÚappend)rJ   rR   rS   Úset_keyÚ	set_valueÚfound_indexesrŒ   rA   r�   rB   Ú__setitem__è   s   
þ
zHeaders.__setitem__c                   sN   |  ¡  | j¡‰ ‡ fdd„t| jƒD ƒ}|st|ƒ‚t|ƒD ]}| j|= qdS )z*
        Remove the header `key`.
        c                   s&   g | ]\}\}}}|  ¡ ˆ kr|‘qS rA   )r:   r‹   ©Údel_keyrA   rB   rC     s
    þz'Headers.__delitem__.<locals>.<listcomp>N)r:   r}   r4   r�   rE   rq   r�   )rJ   rR   Úpop_indexesrŒ   rA   r–   rB   Ú__delitem__   s   
þ
ÿzHeaders.__delitem__c                 C  s$   |  ¡  | j¡}|dd„ | jD ƒv S )Nc                 S  s   g | ]\}}}|‘qS rA   rA   )r=   r[   rR   rA   rA   rB   rC     s    z(Headers.__contains__.<locals>.<listcomp>)r:   r}   r4   rE   )rJ   rR   r…   rA   rA   rB   Ú__contains__  s   zHeaders.__contains__útyping.Iterator[typing.Any]c                 C  s   t |  ¡ ƒS rU   )Úiterrc   r^   rA   rA   rB   Ú__iter__  ó   zHeaders.__iter__Úintc                 C  ó
   t | jƒS rU   )ÚlenrE   r^   rA   rA   rB   Ú__len__  ó   
zHeaders.__len__Úotherc                 C  sR   zt |ƒ}W n
 ty   Y dS w dd„ | jD ƒ}dd„ |jD ƒ}t|ƒt|ƒkS )NFc                 S  ó   g | ]	\}}}||f‘qS rA   rA   ra   rA   rA   rB   rC   "  r\   z"Headers.__eq__.<locals>.<listcomp>c                 S  r¥   rA   rA   ra   rA   rA   rB   rC   #  r\   )r/   Ú
ValueErrorrE   Úsorted)rJ   r¤   Úother_headersÚ	self_listÚ
other_listrA   rA   rB   Ú__eq__  s   ÿzHeaders.__eq__c                 C  sv   | j j}d}| jdkrd| j›�}tt|  ¡ ƒƒ}t|ƒ}t|ƒt|ƒk}|r1|› d|›|› d�S |› d|›|› d�S )NÚ rM   z, encoding=ú(ú))Ú	__class__Ú__name__r4   rG   r+   rn   Údictr¡   )rJ   Ú
class_nameÚencoding_strÚas_listÚas_dictÚno_duplicate_keysrA   rA   rB   Ú__repr__&  s   
zHeaders.__repr__©NN)r2   r3   r4   r5   r6   r7   ©r6   rL   ©rS   rL   r6   r7   )r6   rX   )r6   r_   )r6   rd   )r6   rl   )r6   rm   rU   )rR   rL   ro   rp   r6   rp   )F)rR   rL   rs   rt   r6   ru   )r2   r3   r6   r7   )r6   r/   )rR   rL   r6   rL   ©rR   rL   rS   rL   r6   r7   )rR   rL   r6   r7   )rR   rp   r6   rt   )r6   r›   ©r6   rŸ   )r¤   rp   r6   rt   )r°   Ú
__module__Ú__qualname__Ú__doc__rK   Úpropertyr4   ÚsetterrO   rc   rg   rH   rn   rr   r�   rƒ   r„   rŠ   r•   r™   rš   r�   r¢   r«   r·   rA   rA   rA   rB   r/   ;   s6    ý













r/   c                
   @  sv   e Zd Zddddddddddœ	d1dd„Zd2dd „Zed3d"d#„ƒZd3d$d%„Zd3d&d'„Zd4d)d*„Z	d5d,d-„Z
d6d/d0„ZdS )7r0   N)	Úparamsr2   ÚcookiesÚcontentÚdataÚfilesÚjsonÚstreamÚ
extensionsÚmethodústr | bytesÚurlú	URL | strrÂ   úQueryParamTypes | Noner2   r3   rÃ   úCookieTypes | NonerÄ   úRequestContent | NonerÅ   úRequestData | NonerÆ   úRequestFiles | NonerÇ   útyping.Any | NonerÈ   ú'SyncByteStream | AsyncByteStream | NonerÉ   úRequestExtensions | Noner6   r7   c       	      	   C  sè   t |tƒr| d¡ ¡ n| ¡ | _t|ƒ| _|d ur"| jj|d�| _t|ƒ| _	|d u r-i n|| _
|r9t|ƒ | ¡ |
d u ro| j	 d¡}t||||	t|rR| | j	j¡nd d�d�\}}
|  |¡ |
| _t |
tƒrm|  ¡  d S d S |
| _d S )NrM   )rÂ   zcontent-type)Úcontent_type)rÄ   rÅ   rÆ   rÇ   Úboundary)rF   ÚbytesrP   ÚupperrÊ   r'   rÌ   Úcopy_merge_paramsr/   r2   rÉ   r.   Úset_cookie_headerrr   r	   r   r}   r4   Ú_preparerÈ   r   Úread)rJ   rÊ   rÌ   rÂ   r2   rÃ   rÄ   rÅ   rÆ   rÇ   rÈ   rÉ   rÖ   rA   rA   rB   rK   7  s<   ÿý

ÿý
û

ÿ
zRequest.__init__Údefault_headersúdict[str, str]c                 C  s¦   |  ¡ D ]\}}| ¡ dkrd| jv rq| j ||¡ qg }d| jv }d| jv p,d| jv }|s<| jjr<| d| jjf¡ |sH| jdv rH| d¡ t	|| jj
 ƒ| _d S )Nútransfer-encodingzContent-LengthÚHostzTransfer-Encodings   Host)ÚPOSTÚPUTÚPATCH)s   Content-Lengthó   0)rH   r:   r2   Ú
setdefaultrÌ   Úhostr‘   ÚnetlocrÊ   r/   rO   )rJ   rÞ   rR   rS   Úauto_headersÚhas_hostÚhas_content_lengthrA   rA   rB   rÜ   w  s   
ÿ
zRequest._preparerØ   c                 C  ó   t | dƒstƒ ‚| jS ©NÚ_content)Úhasattrr   rî   r^   rA   rA   rB   rÄ   Œ  ó   
zRequest.contentc                 C  sH   t | dƒs!t| jtjƒsJ ‚d | j¡| _t| jtƒs!t| jƒ| _| jS )ú6
        Read and return the request content.
        rî   ó    )rï   rF   rÈ   ÚtypingÚIterabler‰   rî   r   r^   rA   rA   rB   rÝ   ’  s   
zRequest.readc                 Ã  sZ   �t | dƒs*t| jtjƒsJ ‚d dd„ | j2 ƒI dH ¡| _t| jtƒs*t| jƒ| _| jS )rñ   rî   rò   c                 Ó  ó   �g | z3 d H W }|‘q6 S rU   rA   ©r=   ÚpartrA   rA   rB   rC   ¦  ó   € z!Request.aread.<locals>.<listcomp>N)rï   rF   rÈ   ró   ÚAsyncIterabler‰   rî   r   r^   rA   rA   rB   Úaread   s   €
zRequest.areadrL   c                 C  s,   | j j}t| jƒ}d|› d| j›d|›d�S )Nú<r­   rf   z)>)r¯   r°   rL   rÌ   rÊ   )rJ   r²   rÌ   rA   rA   rB   r·   ®  s   
zRequest.__repr__údict[str, typing.Any]c                 C  ó   dd„ | j  ¡ D ƒS )Nc                 S  ó   i | ]\}}|d vr||“qS ))rÉ   rÈ   rA   ©r=   ÚnamerS   rA   rA   rB   rb   ´  ó
    þz(Request.__getstate__.<locals>.<dictcomp>©Ú__dict__rH   r^   rA   rA   rB   Ú__getstate__³  ó   þzRequest.__getstate__Ústatec                 C  s0   |  ¡ D ]
\}}t| ||ƒ qi | _tƒ | _d S rU   )rH   ÚsetattrrÉ   r   rÈ   ©rJ   r  r   rS   rA   rA   rB   Ú__setstate__º  s   zRequest.__setstate__)rÊ   rË   rÌ   rÍ   rÂ   rÎ   r2   r3   rÃ   rÏ   rÄ   rÐ   rÅ   rÑ   rÆ   rÒ   rÇ   rÓ   rÈ   rÔ   rÉ   rÕ   r6   r7   ©rÞ   rß   r6   r7   ©r6   rØ   r¹   ©r6   rü   ©r  rü   r6   r7   )r°   r½   r¾   rK   rÜ   rÀ   rÄ   rÝ   rú   r·   r  r	  rA   rA   rA   rB   r0   6  s&    ó
@



r0   c                   @  s8  e Zd Zdddddddddddœ
d‚dd„Zdƒdd „Zed„d"d#„ƒZejd…d%d#„ƒZed†d'd(„ƒZejd‡d*d(„ƒZedˆd,d-„ƒZ	edˆd.d/„ƒZ
ed‰d1d2„ƒZedŠd4d5„ƒZedˆd6d7„ƒZed‹d8d9„ƒZejdŒd:d9„ƒZed‹d;d<„ƒZd�d>d?„ZedŽdAdB„ƒZedŽdCdD„ƒZedŽdEdF„ƒZedŽdGdH„ƒZedŽdIdJ„ƒZedŽdKdL„ƒZedŽdMdN„ƒZd�dOdP„Zd�dRdS„Zed‘dUdV„ƒZed’dXdY„ƒZed“dZd[„ƒZdˆd\d]„Zd”d_d`„Zd•dbdc„ZdŠddde„Z d–d—didj„Z!d–d˜dldm„Z"d™dndo„Z#d–d—dpdq„Z$dšdrds„Z%dŠdtdu„Z&	d–d›dwdx„Z'	d–dœdzd{„Z(d�d|d}„Z)	d–d›d~d„Z*dšd€d�„Z+dS )žr1   NrN   )
r2   rÄ   ÚtextÚhtmlrÇ   rÈ   ÚrequestrÉ   ÚhistoryÚdefault_encodingÚstatus_coderŸ   r2   r3   rÄ   úResponseContent | Noner  r5   r  rÇ   rp   rÈ   rÔ   r  úRequest | NonerÉ   úResponseExtensions | Noner  úlist[Response] | Noner  ú#str | typing.Callable[[bytes], str]r6   r7   c       
         C  s¤   || _ t|ƒ| _|| _d | _|	d u ri n|	| _|
d u rg nt|
ƒ| _d| _d| _	|| _
|d u rJt||||ƒ\}}|  |¡ || _t|tƒrI|  ¡  n|| _d| _d S )NFr   )r  r/   r2   Ú_requestÚnext_requestrÉ   rG   r  Ú	is_closedÚis_stream_consumedr  r
   rÜ   rÈ   rF   r   rÝ   Ú_num_bytes_downloaded)rJ   r  r2   rÄ   r  r  rÇ   rÈ   r  rÉ   r  r  rA   rA   rB   rK   Â  s$   


€
zResponse.__init__rÞ   rß   c                 C  s<   |  ¡ D ]\}}| ¡ dkrd| jv rq| j ||¡ qd S )Nrà   zcontent-length)rH   r:   r2   ræ   )rJ   rÞ   rR   rS   rA   rA   rB   rÜ   ù  s
   üzResponse._prepareúdatetime.timedeltac                 C  s   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^   rA   rA   rB   Úelapsed   s
   
ÿzResponse.elapsedr!  c                 C  rT   rU   )r  )rJ   r!  rA   rA   rB   r!    rW   r0   c                 C  s   | j du r	tdƒ‚| j S )zR
        Returns the request instance associated to the current response.
        Nz7The request instance has not been set on this response.)r  r   r^   rA   rA   rB   r    s
   
ÿzResponse.requestrS   c                 C  rT   rU   )r  rV   rA   rA   rB   r    rW   rL   c                 C  s2   z| j d }W n
 ty   Y dS w |jddd�S )NÚhttp_versionzHTTP/1.1rM   Úignore©Úerrors)rÉ   rq   rP   )rJ   r"  rA   rA   rB   r"     s   ÿzResponse.http_versionc                 C  s<   z| j d }W n ty   t | j¡ Y S w |jddd�S )NÚreason_phraserM   r#  r$  )rÉ   rq   r   Úget_reason_phraser  rP   )rJ   r&  rA   rA   rB   r&  )  s   ÿzResponse.reason_phraser'   c                 C  s   | j jS )zA
        Returns the URL for which the request was made.
        )r  rÌ   r^   rA   rA   rB   rÌ   2  s   zResponse.urlrØ   c                 C  rì   rí   )rï   r   rî   r^   rA   rA   rB   rÄ   9  rð   zResponse.contentc                 C  sR   t | dƒs&| j}|sd| _| jS t| jpdd�}d | | j¡| ¡ g¡| _| jS )NÚ_textr¬   rN   r@   )rï   rÄ   r(  r   r4   r‰   rP   Úflush)rJ   rÄ   ÚdecoderrA   rA   rB   r  ?  s   
þzResponse.textc                 C  sZ   t | dƒs*| j}|du st|ƒs%t| 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î   rN   )rï   Úcharset_encodingr(   rF   r  rL   rî   rI   )rJ   r4   rA   rA   rB   r4   J  s   


zResponse.encodingc                 C  s   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.
        r(  z?Setting encoding after `text` has been accessed is not allowed.N)rï   r¦   rI   rV   rA   rA   rB   r4   `  s
   
ÿ
c                 C  s    | j  d¡}|du rdS t|ƒS )zO
        Return the encoding, as specified by the Content-Type header.
        zContent-TypeN)r2   rr   r,   )rJ   rÖ   rA   rA   rB   r+  n  s   zResponse.charset_encodingr   c              	   C  s¦   t | dƒsPg }| jjddd�}|D ]}| ¡  ¡ }zt| }| |ƒ ¡ W q ty.   Y qw t|ƒdkr=|d | _	| j	S t|ƒdkrLt
|d�| _	| j	S 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)rs   r   r   )Úchildren)rï   r2   r�   rz   r:   r   r‘   rq   r¡   r,  r   r   )rJ   Údecodersrg   rS   Údecoder_clsrA   rA   rB   Ú_get_content_decodery  s&   
ÿ
ûþzResponse._get_content_decoderrt   c                 C  ó   t  | j¡S )zU
        A property which is `True` for 1xx status codes, `False` otherwise.
        )r   Úis_informationalr  r^   rA   rA   rB   r2  ’  ó   zResponse.is_informationalc                 C  r1  )zU
        A property which is `True` for 2xx status codes, `False` otherwise.
        )r   Ú
is_successr  r^   rA   rA   rB   r4  ™  r3  zResponse.is_successc                 C  r1  )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^   rA   rA   rB   r5     s   
zResponse.is_redirectc                 C  r1  )zU
        A property which is `True` for 4xx status codes, `False` otherwise.
        )r   Úis_client_errorr  r^   rA   rA   rB   r6  ¬  r3  zResponse.is_client_errorc                 C  r1  )zU
        A property which is `True` for 5xx status codes, `False` otherwise.
        )r   Úis_server_errorr  r^   rA   rA   rB   r7  ³  r3  zResponse.is_server_errorc                 C  r1  )z]
        A property which is `True` for 4xx and 5xx status codes, `False` otherwise.
        )r   Úis_errorr  r^   rA   rA   rB   r8  º  r3  zResponse.is_errorc                 C  s(   | 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_REDIRECTr2   r^   rA   rA   rB   Úhas_redirect_locationÁ  s   öÿòzResponse.has_redirect_locationc                 C  sp   | j }|du rtdƒ‚| jr| S | jrd}nd}| jd }dddd	d
œ}| |d¡}|j| |d�}t||| d�‚)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)r  r   r4  r?  r  rr   Úformatr   )rJ   r  ÚmessageÚstatus_classÚerror_typesrD  rA   rA   rB   Úraise_for_statusØ  s*   ÿÿÿ
üzResponse.raise_for_statusÚkwargsc                 K  s   t j| jfi |¤ŽS rU   )ÚjsonlibÚloadsrÄ   )rJ   rK  rA   rA   rB   rÇ   ý  s   zResponse.jsonr.   c                 C  s$   t | dƒstƒ | _| j | ¡ | jS )NÚ_cookies)rï   r.   rN  Úextract_cookiesr^   rA   rA   rB   rÃ      s   
zResponse.cookiesú dict[str | None, dict[str, str]]c                 C  s*   | j  d¡}|du ri S dd„ t|ƒD ƒS )zI
        Returns the parsed header links of the response, if any
        ÚlinkNc                 S  s"   i | ]}|  d ¡p|  d¡|“qS )ÚrelrÌ   )rr   )r=   rQ  rA   rA   rB   rb     s    ÿÿz"Response.links.<locals>.<dictcomp>)r2   rr   r-   )rJ   ÚheaderrA   rA   rB   Úlinks  s   þzResponse.linksc                 C  s   | j S rU   )r  r^   rA   rA   rB   Únum_bytes_downloaded  s   zResponse.num_bytes_downloadedc                 C  s   d| j › d| j› d�S )Nz<Response [ú ú]>)r  r&  r^   rA   rA   rB   r·     s   zResponse.__repr__rü   c                 C  rý   )Nc                 S  rþ   ))rÉ   rÈ   r  r,  rA   rÿ   rA   rA   rB   rb     r  z)Response.__getstate__.<locals>.<dictcomp>r  r^   rA   rA   rB   r    r  zResponse.__getstate__r  c                 C  s6   |  ¡ D ]
\}}t| ||ƒ qd| _i | _tƒ | _d S )NT)rH   r  r  rÉ   r   rÈ   r  rA   rA   rB   r	  #  s
   zResponse.__setstate__c                 C  s    t | dƒsd |  ¡ ¡| _| jS )ú7
        Read and return the response content.
        rî   rò   )rï   r‰   Ú
iter_bytesrî   r^   rA   rA   rB   rÝ   *  s   
zResponse.readÚ
chunk_sizeú
int | Noneútyping.Iterator[bytes]c                 c  sü   � t | dƒr,|du rt| jƒn|}tdt| jƒt|dƒƒD ]}| j||| … V  qdS |  ¡ }t|d�}t| jd��9 |  	¡ D ]}| 
|¡}| 
|¡D ]}|V  qLq@| ¡ }| 
|¡D ]}|V  q\| ¡ D ]}|V  qfW d  ƒ dS 1 sww   Y  dS ©z˜
        A byte-iterator over the decoded response content.
        This allows us to handle gzip, deflate, brotli, and zstd encoded responses.
        rî   Nr   r   ©rZ  ©r  )rï   r¡   rî   ÚrangeÚmaxr0  r   r   r  Úiter_rawrP   r)  ©rJ   rZ  Úir*  ÚchunkerÚ	raw_bytesÚdecodedÚchunkrA   rA   rB   rY  2  s*   €
ÿ

ÿÿ"øzResponse.iter_bytesútyping.Iterator[str]c                 c  s®   � t | jpdd�}t|d�}t| jd��9 |  ¡ D ]}| |¡}| |¡D ]}|V  q%q| ¡ }| |¡D ]}|V  q5| ¡ D ]}|V  q?W d  ƒ dS 1 sPw   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.
        rN   r@   r^  r_  N)r   r4   r   r   r  rY  rP   r)  ©rJ   rZ  r*  re  Úbyte_contentÚtext_contentrh  rA   rA   rB   Ú	iter_textI  s    €

ÿÿ"øzResponse.iter_textc                 c  sr   � t ƒ }t| jd��% |  ¡ D ]}| |¡D ]}|V  qq| ¡ D ]}|V  q!W d   ƒ d S 1 s2w   Y  d S ©Nr_  )r   r   r  rn  rP   r)  ©rJ   r*  r  ÚlinerA   rA   rB   Ú
iter_lines\  s   €ÿÿ"üzResponse.iter_linesc                 c  sÄ   � | j rtƒ ‚| jrtƒ ‚t| jtƒstdƒ‚d| _ d| _t	|d�}t
| jd��" | jD ]}|  jt|ƒ7  _| |¡D ]}|V  q<q,W d  ƒ n1 sMw   Y  | ¡ D ]}|V  qV|  ¡  dS )ú@
        A byte-iterator over the raw response content.
        z5Attempted to call a sync iterator on an async stream.Tr   r^  r_  N)r  r   r  r   rF   rÈ   r&   r   r  r   r   r  r¡   rP   r)  Úclose©rJ   rZ  re  Úraw_stream_bytesrh  rA   rA   rB   rb  e  s*   €

ÿþÿzResponse.iter_rawc                 C  s`   t | jtƒs
tdƒ‚| js.d| _t| jd�� | j ¡  W d  ƒ dS 1 s'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   r  r   r  rt  r^   rA   rA   rB   rt    s   "ÿþzResponse.closec                 Ã  s2   �t | dƒsd dd„ |  ¡ 2 ƒI dH ¡| _| jS )rX  rî   rò   c                 Ó  rõ   rU   rA   rö   rA   rA   rB   rC   ‘  rø   z"Response.aread.<locals>.<listcomp>N)rï   r‰   Úaiter_bytesrî   r^   rA   rA   rB   rú   Œ  s   €
 zResponse.areadútyping.AsyncIterator[bytes]c                 C s  �t | dƒr,|du rt| jƒn|}tdt| jƒt|dƒƒD ]}| j||| … V  qdS |  ¡ }t|d�}t| jd��> |  	¡ 2 z3 dH W }| 
|¡}| 
|¡D ]}|V  qPq@6 | ¡ }| 
|¡D ]}|V  qa| ¡ D ]}|V  qkW d  ƒ dS 1 s|w   Y  dS r]  )rï   r¡   rî   r`  ra  r0  r   r   r  Ú	aiter_rawrP   r)  rc  rA   rA   rB   rx  ”  s,   €
ÿ

ÿþÿ"øzResponse.aiter_bytesútyping.AsyncIterator[str]c                 C s¸   �t | jpdd�}t|d�}t| jd��> |  ¡ 2 z3 dH W }| |¡}| |¡D ]}|V  q)q6 | ¡ }| |¡D ]}|V  q:| ¡ D ]}|V  qDW d  ƒ dS 1 sUw   Y  dS rj  )r   r4   r   r   r  rx  rP   r)  rk  rA   rA   rB   Ú
aiter_text­  s"   €

ÿþÿ"øzResponse.aiter_textc                 C s|   �t ƒ }t| jd��* |  ¡ 2 z3 d H W }| |¡D ]}|V  qq6 | ¡ D ]}|V  q&W d   ƒ d S 1 s7w   Y  d S ro  )r   r   r  r|  rP   r)  rp  rA   rA   rB   Úaiter_linesÂ  s   €ÿÿÿ"üzResponse.aiter_linesc                 C sÔ   �| j rtƒ ‚| jrtƒ ‚t| jtƒstdƒ‚d| _ d| _t	|d�}t
| jd��' | j2 z3 dH W }|  jt|ƒ7  _| |¡D ]}|V  q@q,6 W d  ƒ n1 sRw   Y  | ¡ D ]}|V  q[|  ¡ I dH  dS )rs  z6Attempted to call an async iterator on an sync stream.Tr   r^  r_  N)r  r   r  r   rF   rÈ   r   r   r  r   r   r  r¡   rP   r)  Úacloseru  rA   rA   rB   rz  Ë  s*   €
ÿþÿzResponse.aiter_rawc                 Ã  sh   �t | jtƒstdƒ‚| js2d| _t| jd�� | j ¡ I dH  W d  ƒ dS 1 s+w   Y  dS dS )rw  z3Attempted to call an async close on an sync stream.Tr_  N)rF   rÈ   r   r   r  r   r  r~  r^   rA   rA   rB   r~  ç  s   €"ÿþzResponse.aclose)r  rŸ   r2   r3   rÄ   r  r  r5   r  r5   rÇ   rp   rÈ   rÔ   r  r  rÉ   r  r  r  r  r  r6   r7   r
  )r6   r  )r!  r  r6   r7   )r6   r0   )rS   r0   r6   r7   r¹   )r6   r'   r  )r6   r5   rº   )r6   r   ©r6   rt   )r6   r1   )rK  rp   r6   rp   )r6   r.   )r6   rP  r¼   r  r  rU   )rZ  r[  r6   r\  )rZ  r[  r6   ri  ©r6   ri  )r6   r7   )rZ  r[  r6   ry  )rZ  r[  r6   r{  )r6   r{  ),r°   r½   r¾   rK   rÜ   rÀ   r!  rÁ   r  r"  r&  rÌ   rÄ   r  r4   r+  r0  r2  r4  r5  r6  r7  r8  r?  rJ  rÇ   rÃ   rT  rU  r·   r  r	  rÝ   rY  rn  rr  rb  rt  rú   rx  r|  r}  rz  r~  rA   rA   rA   rB   r1   Á  sœ    ó
7





%




	

	ÿÿ

ÿr1   c                   @  sÞ   e Zd ZdZd9d:dd„Zd;dd„Zd<dd„Zd=d>dd„Z			d?d@dd„Z		dAdBdd„Z	dAdCd d!„Z
d9d:d"d#„ZdDd$d%„ZdEd&d'„ZdFd(d)„ZdGd+d,„ZdHd.d/„ZdId1d2„ZdJd3d4„ZG d5d6„ d6ejjƒZG d7d8„ d8ƒZdS )Kr.   z-
    HTTP Cookies, as a mutable mapping.
    NrÃ   rÏ   r6   r7   c                 C  s²   |d u s	t |tƒr%tƒ | _t |tƒr!| ¡ D ]\}}|  ||¡ qd S d S t |tƒr=tƒ | _|D ]
\}}|  ||¡ q0d S t |tƒrTtƒ | _|jD ]}| j |¡ qId S || _d S rU   )	rF   r±   r   ÚjarrH   ÚsetrG   r.   Ú
set_cookie)rJ   rÃ   rR   rS   ÚcookierA   rA   rB   rK   ú  s$   
þ
ÿ

ÿ
zCookies.__init__rE  r1   c                 C  s(   |   |¡}|  |j¡}| j ||¡ dS )zO
        Loads any cookies based on the response `Set-Cookie` headers.
        N)Ú_CookieCompatResponseÚ_CookieCompatRequestr  r�  rO  )rJ   rE  Úurllib_responseÚurllib_requestrA   rA   rB   rO    s   
zCookies.extract_cookiesr  r0   c                 C  s   |   |¡}| j |¡ dS )zM
        Sets an appropriate 'Cookie:' HTTP header on the `Request`.
        N)r†  r�  Úadd_cookie_header)rJ   r  rˆ  rA   rA   rB   rÛ     s   
zCookies.set_cookie_headerr¬   ú/r   rL   rS   ÚdomainÚpathc                 C  sš   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   rS   ÚportNÚport_specifiedFr‹  Údomain_specifiedÚdomain_initial_dotÚ.rŒ  Úpath_specifiedÚsecureÚexpiresÚdiscardTÚcommentÚcomment_urlÚrestÚHttpOnlyÚrfc2109rA   )rt   Ú
startswithr   r�  rƒ  )rJ   r   rS   r‹  rŒ  rK  r„  rA   rA   rB   r‚    sJ   ÿþýüûúù
ø	÷
öõôóòñðïzCookies.setro   r5   c                 C  sn   d}| j D ])}|j|kr.|du s|j|kr.|du s|j|kr.|dur+d|› �}t|ƒ‚|j}q|du r5|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   rS   )rJ   r   ro   r‹  rŒ  rS   r„  rG  rA   rA   rB   rr   5  s   


€zCookies.getc                   s\   ˆ durˆdur| j  ˆ ˆˆ¡S ‡ ‡‡fdd„| j D ƒ}|D ]}| j  |j|j|j¡ qdS )z�
        Delete a cookie by name. May optionally include domain and path
        in order to specify exactly which cookie to delete.
        Nc                   s>   g | ]}|j ˆkrˆ d u s|jˆ krˆd u s|jˆkr|‘qS rU   )r   r‹  rŒ  ©r=   r„  ©r‹  r   rŒ  rA   rB   rC   [  s    
üz"Cookies.delete.<locals>.<listcomp>)r�  Úclearr‹  rŒ  r   )rJ   r   r‹  rŒ  Úremover„  rA   rž  rB   ÚdeleteN  s   
þÿzCookies.deletec                 C  sD   g }|dur|  |¡ |dur|dus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Œ  ÚargsrA   rA   rB   rŸ  f  s   

zCookies.clearc                 C  s$   t |ƒ}|jD ]}| j |¡ qd S rU   )r.   r�  rƒ  )rJ   rÃ   r„  rA   rA   rB   rƒ   s  s   
ÿzCookies.updatec                 C  s   |   ||¡S rU   )r‚  ©rJ   r   rS   rA   rA   rB   r•   x  rž   zCookies.__setitem__c                 C  s   |   |¡}|d u rt|ƒ‚|S rU   )rr   rq   r£  rA   rA   rB   rŠ   {  s   
zCookies.__getitem__c                 C  s
   |   |¡S rU   )r¡  )rJ   r   rA   rA   rB   r™   �  r£   zCookies.__delitem__rŸ   c                 C  r    rU   )r¡   r�  r^   rA   rA   rB   r¢   „  r£   zCookies.__len__ri  c                 C  rY   )Nc                 s  s   � | ]}|j V  qd S rU   )r   r�  rA   rA   rB   Ú	<genexpr>ˆ  s   € z#Cookies.__iter__.<locals>.<genexpr>©r�  r^   rA   rA   rB   r�   ‡  s   zCookies.__iter__rt   c                 C  s   | j D ]} dS dS )NTFr¥  )rJ   r[   rA   rA   rB   Ú__bool__Š  s   
zCookies.__bool__c                 C  s"   d  dd„ | jD ƒ¡}d|› d�S )Nrf   c              	   S  s*   g | ]}d |j › d|j› d|j› d�‘qS )z<Cookie ú=z for z />)r   rS   r‹  r�  rA   rA   rB   rC   ‘  s    ÿÿz$Cookies.__repr__.<locals>.<listcomp>z	<Cookies[rW  )r‰   r�  )rJ   Úcookies_reprrA   rA   rB   r·   �  s   þÿzCookies.__repr__c                      s0   e Zd ZdZd‡ fdd„Zd‡ fdd„Z‡  ZS )zCookies._CookieCompatRequestú‚
        Wraps a `Request` instance up in a compatibility interface suitable
        for use with `CookieJar` operations.
        r  r0   r6   r7   c                   s*   t ƒ jt|jƒt|jƒ|jd� || _d S )N)rÌ   r2   rÊ   )ÚsuperrK   rL   rÌ   r±   r2   rÊ   r  )rJ   r  ©r¯   rA   rB   rK   Ÿ  s   ý
z%Cookies._CookieCompatRequest.__init__rR   rL   rS   c                   s   t ƒ  ||¡ || jj|< d S rU   )rª  Úadd_unredirected_headerr  r2   )rJ   rR   rS   r«  rA   rB   r¬  §  s   z4Cookies._CookieCompatRequest.add_unredirected_header©r  r0   r6   r7   r»   )r°   r½   r¾   r¿   rK   r¬  Ú__classcell__rA   rA   r«  rB   r†  ™  s    r†  c                   @  s$   e Zd ZdZddd„Zdd	d
„ZdS )zCookies._CookieCompatResponser©  rE  r1   r6   r7   c                 C  rT   rU   )rE  )rJ   rE  rA   rA   rB   rK   ±  r£   z&Cookies._CookieCompatResponse.__init__úemail.message.Messagec                 C  s,   t j ¡ }| jj ¡ D ]\}}|||< q|S rU   )ÚemailrG  ÚMessagerE  r2   rn   )rJ   ÚinforR   rS   rA   rA   rB   r²  ´  s   

z"Cookies._CookieCompatResponse.infoN©rE  r1   r6   r7   )r6   r¯  )r°   r½   r¾   r¿   rK   r²  rA   rA   rA   rB   r…  «  s    
r…  rU   )rÃ   rÏ   r6   r7   r³  r­  )r¬   rŠ  )
r   rL   rS   rL   r‹  rL   rŒ  rL   r6   r7   )NNN)
r   rL   ro   r5   r‹  r5   rŒ  r5   r6   r5   r¸   )r   rL   r‹  r5   rŒ  r5   r6   r7   )r‹  r5   rŒ  r5   r6   r7   )r   rL   rS   rL   r6   r7   )r   rL   r6   rL   )r   rL   r6   r7   r¼   r€  r  r¹   )r°   r½   r¾   r¿   rK   rO  rÛ   r‚  rr   r¡  rŸ  rƒ   r•   rŠ   r™   r¢   r�   r¦  r·   Úurllibr  r0   r†  r…  rA   rA   rA   rB   r.   õ  s0    

	ûü







r.   )EÚ
__future__r   ÚdatetimeÚemail.messager°  rÇ   rL  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-   Ú__all__ÚMutableMappingrL   r/   r0   r1   r.   rA   rA   rA   rB   Ú<module>   s6    ($
	4 	 |     8