HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/httpx/__pycache__/_models.cpython-310.pyc
o

���g���@s�ddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Zddlm
Z
ddlmZmZddlmZmZmZmZddlmZmZmZmZmZmZmZmZddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&dd	l'm(Z(dd
l)m*Z*ddl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6ddl7m8Z8dd
l9m:Z:m;Z;gd�Z<ddhZ=d3dd�Z>d4d5dd�Z?d4d6dd�Z@d7d!d"�ZAd8d$d%�ZBd9d)d*�ZCGd+d,�d,e	jDeEeEf�ZFGd-d.�d.�ZGGd/d0�d0�ZHGd1d2�d2e	jDeEeEf�ZIdS):�)�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)�to_bytes_or_str�to_str)�Cookies�Headers�Request�Response�
authorizationzproxy-authorization�encoding�str�return�boolcCs&zt�|�WdStyYdSw)z7
    Return `True` if `encoding` is a known codec.
    FT)�codecs�lookup�LookupError�r/�r7�8/usr/local/lib/python3.10/dist-packages/httpx/_models.py�_is_known_encoding8s��r9�key�str | bytes�
str | None�bytescCst|t�r|S|�|pd�S)zE
    Coerce str/bytes into a strictly byte-wise HTTP header key.
    �ascii)�
isinstancer=�encode)r:r/r7r7r8�_normalize_header_keyCsrA�valuecCs8t|t�r|St|t�stdt|�����|�|pd�S)zG
    Coerce str/bytes into a strictly byte-wise HTTP header value.
    z'Header value must be str or bytes, not r>)r?r=r0�	TypeError�typer@)rBr/r7r7r8�_normalize_header_valueJs


rE�content_typecCstj��}||d<|jdd�S)N�content-type)�failobj)�email�message�Message�get_content_charset)rF�msgr7r7r8�_parse_content_type_charsetUs
rN�list[dict[str, str]]c	
Cs�g}d}|�|�}|s
|St�d|�D]M}z
|�dd�\}}Wnty-|d}}Ynwd|�d�i}|�d�D] }z	|�d�\}}Wn
tyOYnw|�|�||�|�<q:|�|�q|S)	a7
    Returns a list of parsed link headers, for more info see:
    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link
    The generic syntax of those is:
    Link: < uri-reference >; param1=value1; param2="value2"
    So for instance:
    Link; '<http:/.../front.jpeg>; type="image/jpeg",<http://.../back.jpeg>;'
    would return
        [
            {"url": "http:/.../front.jpeg", "type": "image/jpeg"},
            {"url": "http://.../back.jpeg"},
        ]
    :param value: HTTP Link entity-header field
    :return: list of parsed link headers
    z '"z, *<�;r��urlz<> '"�=)�strip�re�split�
ValueError�append)	rB�links�
replace_chars�valrR�params�link�paramr:r7r7r8�_parse_header_links]s*
��r_�items�4typing.Iterable[tuple[typing.AnyStr, typing.AnyStr]]�4typing.Iterator[tuple[typing.AnyStr, typing.AnyStr]]ccs:�|D]\}}t|���tvrtd|d�}||fVqdS)Nz[secure])�
match_type_of)r)�lower�SENSITIVE_HEADERSr()r`�k�vr7r7r8�_obfuscate_sensitive_headers�s��rhc@s�eZdZdZ		dAdBd	d
�ZedCdd
��ZejdDdd
��ZedEdd��ZdFdd�Z	dGdd�Z
dHdd�ZdIdd�ZdJdKd"d#�Z
dLdMd(d)�ZdJdNd*d+�ZdOd,d-�ZdPd.d/�ZdQd0d1�ZdRd2d3�ZdSd4d5�ZdTd7d8�ZdUd:d;�ZdVd=d>�ZdCd?d@�ZdS)Wr+z9
    HTTP headers, as a case-insensitive multi-dict.
    N�headers�HeaderTypes | Noner/r<r1�NonecCs�g|_t|t�rt|j�|_nDt|t�r3|��D]\}}t||�}t||�}|j�||�	�|f�qn |durS|D]\}}t||�}t||�}|j�||�	�|f�q9||_
dS�N)�_listr?r+�listrr`rArErXrd�	_encoding)�selfrir/rfrg�	bytes_key�bytes_valuer7r7r8�__init__�s



�


zHeaders.__init__r0c
Csj|jdur2dD]'}|jD]\}}z|�|�|�|�Wqty&Ynw||_|jSqd|_|jS)zn
        Header encoding is mandated as ascii, but we allow fallbacks to utf-8
        or iso-8859-1.
        N)r>�utf-8z
iso-8859-1)ro�raw�decode�UnicodeDecodeError)rpr/r:rBr7r7r8r/�s

��	zHeaders.encodingrBcC�
||_dSrl)ro�rprBr7r7r8r/��
�list[tuple[bytes, bytes]]cC�dd�|jD�S)zH
        Returns a list of the raw header items, as byte pairs.
        cSsg|]	\}}}||f�qSr7r7)�.0�raw_key�_rBr7r7r8�
<listcomp>��zHeaders.raw.<locals>.<listcomp>�rm�rpr7r7r8ru�szHeaders.raw�typing.KeysView[str]cs�fdd��jD���S)Ncs i|]\}}}|��j�d�qSrl�rvr/�r}rr:rBr�r7r8�
<dictcomp>�s z Headers.keys.<locals>.<dictcomp>)rm�keysr�r7r�r8r��szHeaders.keys�typing.ValuesView[str]cC�^i}|jD]%\}}}|�|j�}|�|j�}||vr&||d|��7<q|||<q|��S)N�, )rmrvr/�values�rp�values_dictrr:rB�str_key�	str_valuer7r7r8r��s
zHeaders.values�typing.ItemsView[str, str]cCr�)z�
        Return `(key, value)` items of headers. Concatenate headers
        into a single comma separated value when a key occurs multiple times.
        r�)rmrvr/r`r�r7r7r8r`�s
z
Headers.items�list[tuple[str, str]]cs�fdd��jD�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.
        cs*g|]\}}}|��j�|��j�f�qSr7r�r�r�r7r8r��s��z'Headers.multi_items.<locals>.<listcomp>r�r�r7r�r8�multi_items�s
�zHeaders.multi_itemsr:�default�
typing.AnycCs"z||WSty|YSw)z�
        Return a header value. If multiple occurrences of the header occur
        then concatenate them together with commas.
        )�KeyError)rpr:r�r7r7r8�get�s

�zHeaders.getF�split_commasr2�	list[str]csZ|����j����fdd��jD�}|s|Sg}|D]}|�dd�|�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.
        cs*g|]\}}}|���kr|��j��qSr7)rdrvr/)r}r�item_key�
item_value��get_header_keyrpr7r8r�s

�z$Headers.get_list.<locals>.<listcomp>cSsg|]}|���qSr7)rT)r}�itemr7r7r8r�s�,)rdr@r/rm�extendrV)rpr:r�r��split_valuesrBr7r�r8�get_list�s�zHeaders.get_listcCs:t|�}|��D]}||vr|�|�q|j�|j�dSrl)r+r��poprmr�)rprir:r7r7r8�updates
�zHeaders.updatecCst||jd�S)Nr6)r+r/r�r7r7r8�copyszHeaders.copycs<|����j����fdd��jD�}|rd�|�St|��)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
        cs&g|]\}}}|�kr|��j��qSr7r�)r}r�
header_key�header_value��normalized_keyrpr7r8r�%s

�z'Headers.__getitem__.<locals>.<listcomp>r�)rdr@r/rm�joinr�)rpr:r`r7r�r8�__getitem__s�
zHeaders.__getitem__cs�|�|jpd�}|�|jpd�}|����fdd�t|j�D�}t|dd��D]}|j|=q(|r?|d}|�|f|j|<dS|j�|�|f�dS)zs
        Set the header `key` to `value`, removing any duplicate entries.
        Retains insertion order.
        rtcs"g|]
\}\}}}|�kr|�qSr7r7�r}�idxrr���
lookup_keyr7r8r�9s
�z'Headers.__setitem__.<locals>.<listcomp>rNr)r@rord�	enumeraterm�reversedrX)rpr:rB�set_key�	set_value�
found_indexesr�r7r�r8�__setitem__0s
�
zHeaders.__setitem__csN|���|j���fdd�t|j�D�}|st|��t|�D]}|j|=qdS)z*
        Remove the header `key`.
        cs&g|]\}\}}}|���kr|�qSr7)rdr���del_keyr7r8r�Ns
�z'Headers.__delitem__.<locals>.<listcomp>N)rdr@r/r�rmr�r�)rpr:�pop_indexesr�r7r�r8�__delitem__Hs
�
�zHeaders.__delitem__cCs$|���|j�}|dd�|jD�vS)NcSsg|]\}}}|�qSr7r7)r}rr:r7r7r8r�\sz(Headers.__contains__.<locals>.<listcomp>)rdr@r/rm)rpr:r�r7r7r8�__contains__ZszHeaders.__contains__�typing.Iterator[typing.Any]cCst|���Srl)�iterr�r�r7r7r8�__iter__^�zHeaders.__iter__�intcC�
t|j�Srl)�lenrmr�r7r7r8�__len__a�
zHeaders.__len__�othercCsRzt|�}Wn
tyYdSwdd�|jD�}dd�|jD�}t|�t|�kS)NFcS�g|]	\}}}||f�qSr7r7r�r7r7r8r�jr�z"Headers.__eq__.<locals>.<listcomp>cSr�r7r7r�r7r7r8r�kr�)r+rWrm�sorted)rpr��
other_headers�	self_list�
other_listr7r7r8�__eq__ds�zHeaders.__eq__cCsv|jj}d}|jdkrd|j��}tt|����}t|�}t|�t|�k}|r1|�d|�|�d�S|�d|�|�d�S)NrQr>z, encoding=�(�))�	__class__�__name__r/rnrhr��dictr�)rp�
class_name�encoding_str�as_list�as_dict�no_duplicate_keysr7r7r8�__repr__ns
zHeaders.__repr__�NN)rirjr/r<r1rk�r1r0�rBr0r1rk)r1r{)r1r�)r1r�)r1r�)r1r�rl)r:r0r�r�r1r�)F)r:r0r�r2r1r�)rirjr1rk)r1r+)r:r0r1r0�r:r0rBr0r1rk)r:r0r1rk)r:r�r1r2)r1r��r1r�)r�r�r1r2)r��
__module__�__qualname__�__doc__rs�propertyr/�setterrur�r�r`r�r�r�r�r�r�r�r�r�r�r�r�r�r7r7r7r8r+�s6�













r+c
@sveZdZdddddddddd�	d0dd�Zd1dd �Zed2d"d#��Zd2d$d%�Zd2d&d'�Zd3d(d)�Z	d4d+d,�Z
d5d.d/�ZdS)6r,N)	r\ri�cookies�content�data�files�json�stream�
extensions�methodr0rR�	URL | strr\�QueryParamTypes | Nonerirjr��CookieTypes | Noner��RequestContent | Noner��RequestData | Noner��RequestFiles | Noner��typing.Any | Noner��'SyncByteStream | AsyncByteStream | Noner��RequestExtensions | Noner1rkc	
	Cs�|��|_|dur
t|�nt||d�|_t|�|_|durint|�|_|r-t|��	|�|
durc|j�
d�}t||||	t|rF|�
|jj�ndd�d�\}}
|�|�|
|_t|
t�ra|��dSdS|
|_dS)N)r\rG)rF)r�r�r�r��boundary)�upperr�r'rRr+rir�r�r*�set_cookie_headerr�r	rr@r/�_preparer�r?r�read)
rpr�rRr\rir�r�r�r�r�r�r�rFr7r7r8rss2

��
�

�
zRequest.__init__�default_headers�dict[str, str]cCs�|��D]\}}|��dkrd|jvrq|j�||�qg}d|jv}d|jvp,d|jv}|s<|jjr<|�d|jjf�|sH|jdvrH|�d�t	||jj
�|_dS)N�transfer-encodingzContent-Length�HostzTransfer-EncodingsHost)�POST�PUT�PATCH)sContent-Length�0)r`rdri�
setdefaultrR�hostrX�netlocr�r+ru)rpr�r:rB�auto_headers�has_host�has_content_lengthr7r7r8r��s
�
zRequest._preparer=cC�t|d�st��|jS�N�_content)�hasattrrrr�r7r7r8r���
zRequest.contentcCsHt|d�s!t|jtj�sJ�d�|j�|_t|jt�s!t|j�|_|jS)�6
        Read and return the request content.
        r�)rr?r��typing�Iterabler�rrr�r7r7r8r��s
zRequest.readc�sZ�t|d�s*t|jtj�sJ�d�dd�|j2�IdH�|_t|jt�s*t|j�|_|jS)r	rr
c���g|z3dHW}|�q6Srlr7�r}�partr7r7r8r����z!Request.aread.<locals>.<listcomp>N)rr?r�r�
AsyncIterabler�rrr�r7r7r8�aread�s�
z
Request.areadcCs,|jj}t|j�}d|�d|j�d|�d�S)N�<r�r�z)>)r�r�r0rRr�)rpr�rRr7r7r8r��s
zRequest.__repr__�dict[str, typing.Any]cC�dd�|j��D�S)NcS�i|]\}}|dvr||�qS))r�r�r7�r}�namerBr7r7r8r���
�z(Request.__getstate__.<locals>.<dictcomp>��__dict__r`r�r7r7r8�__getstate__���zRequest.__getstate__�statecCs0|��D]
\}}t|||�qi|_t�|_dSrl)r`�setattrr�rr��rprrrBr7r7r8�__setstate__�szRequest.__setstate__)r�r0rRr�r\r�rirjr�r�r�r�r�r�r�r�r�r�r�r�r�r�r1rk�r�r�r1rk�r1r=r��r1r�rrr1rk)r�r�r�rsr�r�r�r�rr�rr!r7r7r7r8r,~s&�
:



r,c@s8eZdZddddddddddd�
d�dd�Zd�dd �Zed�d"d#��Zejd�d%d#��Zed�d'd(��Zejd�d*d(��Zed�d,d-��Z	ed�d.d/��Z
ed�d1d2��Zed�d4d5��Zed�d6d7��Z
ed�d8d9��Zejd�d:d9��Zed�d;d<��Zd�d>d?�Zed�dAdB��Zed�dCdD��Zed�dEdF��Zed�dGdH��Zed�dIdJ��Zed�dKdL��Zed�dMdN��Zd�dOdP�Zd�dRdS�Zed�dUdV��Zed�dXdY��Zed�dZd[��Zd�d\d]�Zd�d_d`�Zd�dbdc�Zd�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+dS)�r-Nrt)
rir��text�htmlr�r��requestr��history�default_encoding�status_coder�rirjr��ResponseContent | Noner&r<r'r�r�r�r�r(�Request | Noner��ResponseExtensions | Noner)�list[Response] | Noner*�#str | typing.Callable[[bytes], str]r1rkc
Cs�||_t|�|_||_d|_|	durint|	�|_|
durgnt|
�|_d|_	d|_
||_|durLt||||�\}}|�
|�||_t|t�rK|��n||_d|_dS)NFr)r+r+ri�_request�next_requestr�r�rnr)�	is_closed�is_stream_consumedr*r
r�r�r?rr��_num_bytes_downloaded)rpr+rir�r&r'r�r�r(r�r)r*r7r7r8rss$


�
zResponse.__init__r�r�cCs<|��D]\}}|��dkrd|jvrq|j�||�qdS)Nr�zcontent-length)r`rdrir�)rpr�r:rBr7r7r8r�;s
�zResponse._prepare�datetime.timedeltacCst|d�s	td��|jS)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�RuntimeErrorr7r�r7r7r8�elapsedBs

�zResponse.elapsedr9cCrxrl)r7)rpr9r7r7r8r9Orzr,cCs|jdur	td��|jS)zR
        Returns the request instance associated to the current response.
        Nz7The request instance has not been set on this response.)r1r8r�r7r7r8r(Ss

�zResponse.requestrBcCrxrl)r1ryr7r7r8r(^rzr0cCs2z|jd}Wn
tyYdSw|jddd�S)N�http_versionzHTTP/1.1r>�ignore��errors)r�r�rv)rpr:r7r7r8r:bs�zResponse.http_versioncCs<z|jd}Wntyt�|j�YSw|jddd�S)N�
reason_phraser>r;r<)r�r�r�get_reason_phraser+rv)rpr>r7r7r8r>ks�zResponse.reason_phraser'cCs|jjS)zA
        Returns the URL for which the request was made.
        )r(rRr�r7r7r8rRtszResponse.urlr=cCrr)rrrr�r7r7r8r�{rzResponse.contentcCsRt|d�s&|j}|sd|_|jSt|jpdd�}d�|�|j�|��g�|_|jS)N�_textrQrtr6)rr�r@rr/r�rv�flush)rpr��decoderr7r7r8r&�s
�z
Response.textcCsZt|d�s*|j}|dust|�s%t|jt�r|j}nt|d�r%|�|j�}|p(d|_|jS)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.
        roNrrt)r�charset_encodingr9r?r*r0rro)rpr/r7r7r8r/�s


zResponse.encodingcCst|d�r	td��||_dS)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)rrWroryr7r7r8r/�s

�
cCs |j�d�}|durdSt|�S)zO
        Return the encoding, as specified by the Content-Type header.
        zContent-TypeN)rir�rN)rprFr7r7r8rC�szResponse.charset_encodingr
c	Cs�t|d�sPg}|jjddd�}|D]}|����}zt|}|�|��Wqty.Yqwt|�dkr=|d|_	|j	St|�dkrLt
|d�|_	|j	St�|_	|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.
        �_decoderzcontent-encodingT)r�rr)�children)rrir�rTrdrrXr�r�rDrr)rp�decodersr�rB�decoder_clsr7r7r8�_get_content_decoder�s&
�
��zResponse._get_content_decoderr2cC�t�|j�S)zU
        A property which is `True` for 1xx status codes, `False` otherwise.
        )r�is_informationalr+r�r7r7r8rJ��zResponse.is_informationalcCrI)zU
        A property which is `True` for 2xx status codes, `False` otherwise.
        )r�
is_successr+r�r7r7r8rL�rKzResponse.is_successcCrI)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�r7r7r8rM�s
zResponse.is_redirectcCrI)zU
        A property which is `True` for 4xx status codes, `False` otherwise.
        )r�is_client_errorr+r�r7r7r8rN�rKzResponse.is_client_errorcCrI)zU
        A property which is `True` for 5xx status codes, `False` otherwise.
        )r�is_server_errorr+r�r7r7r8rO�rKzResponse.is_server_errorcCrI)z]
        A property which is `True` for 4xx and 5xx status codes, `False` otherwise.
        )r�is_errorr+r�r7r7r8rP�rKzResponse.is_errorcCs(|jtjtjtjtjtjfvod|jvS)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_REDIRECTrir�r7r7r8�has_redirect_locations��
�zResponse.has_redirect_locationcCsp|j}|durtd��|jr|S|jrd}nd}|jd}dddd	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}�dzInformational responsezRedirect responsezClient errorzServer error)r���zInvalid status code)�
error_type)r(�response)r1r8rLrWr+r��formatr)rpr(rJ�status_class�error_typesr\r7r7r8�raise_for_statuss*���
�zResponse.raise_for_status�kwargscKstj|jfi|��Srl)�jsonlib�loadsr�)rprbr7r7r8r�?sz
Response.jsonr*cCs$t|d�st�|_|j�|�|jS)N�_cookies)rr*re�extract_cookiesr�r7r7r8r�Bs
zResponse.cookies� dict[str | None, dict[str, str]]cCs*|j�d�}|duriSdd�t|�D�S)zI
        Returns the parsed header links of the response, if any
        r]NcSs"i|]
}|�d�p
|�d�|�qS)�relrR)r�)r}r]r7r7r8r�Rs��z"Response.links.<locals>.<dictcomp>)rir�r_)rp�headerr7r7r8rYIs�zResponse.linkscCs|jSrl)r5r�r7r7r8�num_bytes_downloadedWszResponse.num_bytes_downloadedcCsd|j�d|j�d�S)Nz<Response [� �]>)r+r>r�r7r7r8r�[szResponse.__repr__rcCr)NcSr))r�r�r3rDr7rr7r7r8r�_rz)Response.__getstate__.<locals>.<dictcomp>rr�r7r7r8r^rzResponse.__getstate__rcCs6|��D]
\}}t|||�qd|_i|_t�|_dS)NT)r`rr3r�rr�r r7r7r8r!es
zResponse.__setstate__cCs t|d�s
d�|���|_|jS)�7
        Read and return the response content.
        rr
)rr��
iter_bytesrr�r7r7r8r�ls
z
Response.read�
chunk_size�
int | None�typing.Iterator[bytes]ccs��t|d�r,|durt|j�n|}tdt|j�t|d��D]}|j|||�VqdS|��}t|d�}t|jd��9|�	�D]}|�
|�}|�
|�D]}|VqLq@|��}|�
|�D]}|Vq\|��D]}|VqfWd�dS1swwYdS�z�
        A byte-iterator over the decoded response content.
        This allows us to handle gzip, deflate, brotli, and zstd encoded responses.
        rNrr�ro�r()rr�r�range�maxrHrrr1�iter_rawrvrA�rpro�irB�chunker�	raw_bytes�decoded�chunkr7r7r8rnts*�
�

��"�zResponse.iter_bytes�typing.Iterator[str]ccs��t|jpdd�}t|d�}t|jd��9|��D]}|�|�}|�|�D]}|Vq%q|��}|�|�D]}|Vq5|��D]}|Vq?Wd�dS1sPwYdS�z�
        A str-iterator over the decoded response content
        that handles both gzip, deflate, etc but also detects the content's
        string encoding.
        rtr6rsrtN)rr/rrr1rnrvrA�rprorBrz�byte_content�text_contentr}r7r7r8�	iter_text�s �

��"�zResponse.iter_textccsr�t�}t|jd��%|��D]
}|�|�D]}|Vqq|��D]}|Vq!Wd�dS1s2wYdS�Nrt)rrr1r�rvrA�rprBr&�liner7r7r8�
iter_lines�s���"�zResponse.iter_linesccs��|jrt��|jr
t��t|jt�std��d|_d|_t	|d�}t
|jd��"|jD]}|jt|�7_|�
|�D]}|Vq<q,Wd�n1sMwY|��D]}|VqV|��dS)�@
        A byte-iterator over the raw response content.
        z5Attempted to call a sync iterator on an async stream.TrrsrtN)r4rr3rr?r�r&r8r5rrr1r�rvrA�close�rprorz�raw_stream_bytesr}r7r7r8rw�s*�

���zResponse.iter_rawcCs`t|jt�s
td��|js.d|_t|jd��|j��Wd�dS1s'wYdSdS)��
        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.TrtN)r?r�r&r8r3rr1r�r�r7r7r8r��s"��zResponse.closec�s2�t|d�sd�dd�|��2�IdH�|_|jS)rmrr
c�r
rlr7rr7r7r8r��rz"Response.aread.<locals>.<listcomp>N)rr��aiter_bytesrr�r7r7r8r�s�
 zResponse.aread�typing.AsyncIterator[bytes]cCs�t|d�r,|durt|j�n|}tdt|j�t|d��D]}|j|||�VqdS|��}t|d�}t|jd��>|�	�2z3dHW}|�
|�}|�
|�D]}|VqPq@6|��}|�
|�D]}|Vqa|��D]}|VqkWd�dS1s|wYdSrr)rr�rrurvrHrrr1�	aiter_rawrvrArxr7r7r8r��s,�
�

���"�zResponse.aiter_bytes�typing.AsyncIterator[str]cCs��t|jpdd�}t|d�}t|jd��>|��2z3dHW}|�|�}|�|�D]}|Vq)q6|��}|�|�D]}|Vq:|��D]}|VqDWd�dS1sUwYdSr)rr/rrr1r�rvrAr�r7r7r8�
aiter_text�s"�

���"�zResponse.aiter_textcCs|�t�}t|jd��*|��2z3dHW}|�|�D]}|Vqq6|��D]}|Vq&Wd�dS1s7wYdSr�)rrr1r�rvrAr�r7r7r8�aiter_liness����"�zResponse.aiter_linescCs��|jrt��|jr
t��t|jt�std��d|_d|_t	|d�}t
|jd��'|j2z3dHW}|jt|�7_|�
|�D]}|Vq@q,6Wd�n1sRwY|��D]}|Vq[|��IdHdS)r�z6Attempted to call an async iterator on an sync stream.TrrsrtN)r4rr3rr?r�rr8r5rrr1r�rvrA�acloser�r7r7r8r�
s*�
���zResponse.aiter_rawc�sh�t|jt�std��|js2d|_t|jd��|j��IdHWd�dS1s+wYdSdS)r�z3Attempted to call an async close on an sync stream.TrtN)r?r�rr8r3rr1r�r�r7r7r8r�)s�"��zResponse.aclose)r+r�rirjr�r,r&r<r'r<r�r�r�r�r(r-r�r.r)r/r*r0r1rkr")r1r6)r9r6r1rk)r1r,)rBr,r1rkr�)r1r'r#)r1r<r�)r1r
�r1r2)r1r-)rbr�r1r�)r1r*)r1rgr�r$r%rl)rorpr1rq)rorpr1r~�r1r~)r1rk)rorpr1r�)rorpr1r�)r1r�),r�r�r�rsr�r�r9r�r(r:r>rRr�r&r/rCrHrJrLrMrNrOrPrWrar�r�rYrjr�rr!r�rnr�r�rwr�rr�r�r�r�r�r7r7r7r8r-s��
7






%





	


	��

�r-c@s�eZdZdZd9d:dd�Zd;dd�Zd<dd�Zd=d>dd�Z			d?d@dd�Z		dAdBdd�Z	dAdCd d!�Z
d9d:d"d#�ZdDd$d%�ZdEd&d'�Z
dFd(d)�ZdGd+d,�ZdHd.d/�ZdId1d2�ZdJd3d4�ZGd5d6�d6ejj�ZGd7d8�d8�ZdS)Kr*z-
    HTTP Cookies, as a mutable mapping.
    Nr�r�r1rkcCs�|dus	t|t�r%t�|_t|t�r!|��D]\}}|�||�qdSdSt|t�r=t�|_|D]
\}}|�||�q0dSt|t�rTt�|_|jD]}|j�|�qIdS||_dSrl)	r?r�r�jarr`�setrnr*�
set_cookie)rpr�r:rB�cookier7r7r8rs<s$
�
�

�
zCookies.__init__r]r-cCs(|�|�}|�|j�}|j�||�dS)zO
        Loads any cookies based on the response `Set-Cookie` headers.
        N)�_CookieCompatResponse�_CookieCompatRequestr(r�rf)rpr]�urllib_response�urllib_requestr7r7r8rfMs
zCookies.extract_cookiesr(r,cCs|�|�}|j�|�dS)zM
        Sets an appropriate 'Cookie:' HTTP header on the `Request`.
        N)r�r��add_cookie_header)rpr(r�r7r7r8r�Vs
zCookies.set_cookie_headerrQ�/rr0rB�domain�pathcCs�idd�d|�d|�dd�dd�d	|�d
t|��d|�d��d
|�dt|��dd�dd�dd�dd�dd�dddi�dd�}tdi|��}|j�|�dS)zU
        Set a cookie value by name. May optionally include domain and path.
        �versionrrrB�portN�port_specifiedFr��domain_specified�domain_initial_dot�.r��path_specified�secure�expires�discardT�comment�comment_url�rest�HttpOnly�rfc2109r7)r2�
startswithrr�r�)rprrBr�r�rbr�r7r7r8r�]sJ�������
�	�
���
�����zCookies.setr�r<cCsnd}|jD])}|j|kr.|dus|j|kr.|dus|j|kr.|dur+d|��}t|��|j}q|dur5|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�rr�r�rrB)rprr�r�r�rBr�rJr7r7r8r�ws


�zCookies.getcs\�dur�dur|j�����S���fdd�|jD�}|D]
}|j�|j|j|j�qdS)z�
        Delete a cookie by name. May optionally include domain and path
        in order to specify exactly which cookie to delete.
        Ncs>g|]}|j�kr�dus|j�kr�dus|j�kr|�qSrl)rr�r��r}r��r�rr�r7r8r��s
�z"Cookies.delete.<locals>.<listcomp>)r��clearr�r�r)rprr�r��remover�r7r�r8�delete�s
��zCookies.deletecCsDg}|dur|�|�|dur|dusJ�|�|�|jj|�dS)z�
        Delete all cookies. Optionally include a domain and path in
        order to only delete a subset of all the cookies.
        N)rXr�r�)rpr�r��argsr7r7r8r��s

z
Cookies.clearcCs$t|�}|jD]}|j�|�qdSrl)r*r�r�)rpr�r�r7r7r8r��s
�zCookies.updatecCs|�||�Srl)r��rprrBr7r7r8r��r�zCookies.__setitem__cCs|�|�}|dur
t|��|Srl)r�r�r�r7r7r8r��s
zCookies.__getitem__cCs
|�|�Srl)r�)rprr7r7r8r��r�zCookies.__delitem__r�cCr�rl)r�r�r�r7r7r8r��r�zCookies.__len__r~cCr|)Ncss�|]}|jVqdSrl)rr�r7r7r8�	<genexpr>�s�z#Cookies.__iter__.<locals>.<genexpr>�r�r�r7r7r8r��szCookies.__iter__r2cCs|jD]}dSdS)NTFr�)rprr7r7r8�__bool__�s
zCookies.__bool__cCs"d�dd�|jD��}d|�d�S)Nr�c	Ss*g|]}d|j�d|j�d|j�d��qS)z<Cookie rSz for z />)rrBr�r�r7r7r8r��s��z$Cookies.__repr__.<locals>.<listcomp>z	<Cookies[rl)r�r�)rp�cookies_reprr7r7r8r��s��zCookies.__repr__cs0eZdZdZd
�fdd�Zd�fdd�Z�ZS)zCookies._CookieCompatRequest��
        Wraps a `Request` instance up in a compatibility interface suitable
        for use with `CookieJar` operations.
        r(r,r1rkcs*t�jt|j�t|j�|jd�||_dS)N)rRrir�)�superrsr0rRr�rir�r()rpr(�r�r7r8rs�s�
z%Cookies._CookieCompatRequest.__init__r:r0rBcst��||�||jj|<dSrl)r��add_unredirected_headerr(ri)rpr:rBr�r7r8r��sz4Cookies._CookieCompatRequest.add_unredirected_header�r(r,r1rkr�)r�r�r�r�rsr��
__classcell__r7r7r�r8r��sr�c@s$eZdZdZddd�Zd
d	d
�ZdS)zCookies._CookieCompatResponser�r]r-r1rkcCrxrl)r])rpr]r7r7r8rs�r�z&Cookies._CookieCompatResponse.__init__�email.message.MessagecCs,tj��}|jj��D]\}}|||<q|Srl)rIrJrKr]rir�)rp�infor:rBr7r7r8r��s

z"Cookies._CookieCompatResponse.infoN�r]r-r1rk)r1r�)r�r�r�r�rsr�r7r7r7r8r��s
r�rl)r�r�r1rkr�r�)rQr�)
rr0rBr0r�r0r�r0r1rk)NNN)
rr0r�r<r�r<r�r<r1r<r�)rr0r�r<r�r<r1rk)r�r<r�r<r1rk)rr0rBr0r1rk)rr0r1r0)rr0r1rkr�r�r�r�)r�r�r�r�rsrfr�r�r�r�r�r�r�r�r�r�r�r�r��urllibr(r,r�r�r7r7r7r8r*7s0

	��







r*)r/r0r1r2rl)r:r;r/r<r1r=)rBr;r/r<r1r=)rFr0r1r<)rBr0r1rO)r`rar1rb)J�
__future__rr3�datetime�
email.messagerIr�rcrUr�urllib.requestr��collections.abcr�http.cookiejarrrrrrr	r
�	_decodersrrr
rrrrr�_exceptionsrrrrrrr�
_multipartr�
_status_codesr�_typesrrrrr r!r"r#r$r%r&�_urlsr'�_utilsr(r)�__all__rer9rArErNr_rh�MutableMappingr0r+r,r-r*r7r7r7r8�<module>sH($
	4




%	t8