o
    ûÞhÛ   ã                   @  s�  U d dl mZ d dlZd dlZd dlmZ d dlmZ ddlm	Z	 ddl
mZ ejr0d d	lmZ d
Zeg d¢ƒZdZzzd dlZW n eyN   d dlZY nw W n	 eyY   Y nw ed7 Zzd dlmZ ed7 ZW n ey‡   z
d dlZed7 ZW n	 ey„   Y nw Y nw G dd„ deƒZejZded< ejeef Z h d£Z!						d7d8d d!„Z"d9d&d'„Z#d:d,d-„Z$G d.d/„ d/ej%ƒZ&d;d5d6„Z'dS )<é    )ÚannotationsN)Ú	b64encode)ÚEnumé   )ÚUnrewindableBodyErroré   )Úto_bytes)ÚFinalz@@@SKIP_HEADER@@@)úaccept-encodingÚhostú
user-agentzgzip,deflatez,br)Úzstdz,zstdc                   @  s   e Zd ZdZdS )Ú_TYPE_FAILEDTELLr   N)Ú__name__Ú
__module__Ú__qualname__Útoken© r   r   úT/var/www/html/premium_crap/venv/lib/python3.10/site-packages/urllib3/util/request.pyr   /   s    r   zFinal[_TYPE_FAILEDTELL]Ú_FAILEDTELL>   ÚGETÚHEADÚTRACEÚDELETEÚCONNECTÚOPTIONSÚ
keep_aliveúbool | NoneÚaccept_encodingúbool | list[str] | str | NoneÚ
user_agentú
str | NoneÚ
basic_authÚproxy_basic_authÚdisable_cacheÚreturnúdict[str, str]c                 C  sž   i }|rt |tƒr
nt |tƒrd |¡}nt}||d< |r!||d< | r'd|d< |r7dt| d¡ƒ ¡ › �|d< |rGdt| d¡ƒ ¡ › �|d	< |rMd
|d< |S )ad  
    Shortcuts for generating request headers.

    :param keep_alive:
        If ``True``, adds 'connection: keep-alive' header.

    :param accept_encoding:
        Can be a boolean, list, or string.
        ``True`` translates to 'gzip,deflate'.  If the dependencies for
        Brotli (either the ``brotli`` or ``brotlicffi`` package) and/or Zstandard
        (the ``zstandard`` package) algorithms are installed, then their encodings are
        included in the string ('br' and 'zstd', respectively).
        List will get joined by comma.
        String will be used as provided.

    :param user_agent:
        String representing the user-agent you want, such as
        "python-urllib3/0.6"

    :param basic_auth:
        Colon-separated username:password string for 'authorization: basic ...'
        auth header.

    :param proxy_basic_auth:
        Colon-separated username:password string for 'proxy-authorization: basic ...'
        auth header.

    :param disable_cache:
        If ``True``, adds 'cache-control: no-cache' header.

    Example:

    .. code-block:: python

        import urllib3

        print(urllib3.util.make_headers(keep_alive=True, user_agent="Batman/1.0"))
        # {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'}
        print(urllib3.util.make_headers(accept_encoding=True))
        # {'accept-encoding': 'gzip,deflate'}
    ú,r
   r   z
keep-aliveÚ
connectionzBasic zlatin-1Úauthorizationzproxy-authorizationzno-cachezcache-control)Ú
isinstanceÚstrÚlistÚjoinÚACCEPT_ENCODINGr   ÚencodeÚdecode)r   r   r    r"   r#   r$   Úheadersr   r   r   Úmake_headers?   s*   1

ÿÿr2   Úbodyú
typing.AnyÚposú_TYPE_BODY_POSITION | Nonec                 C  sR   |durt | |ƒ |S t| ddƒdur'z|  ¡ }W |S  ty&   t}Y |S w |S )z
    If a position is provided, move file to that point.
    Otherwise, we'll attempt to record a position for future use.
    NÚtell)Úrewind_bodyÚgetattrr7   ÚOSErrorr   )r3   r5   r   r   r   Úset_file_position�   s   
	ø
ûûr;   útyping.IO[typing.AnyStr]Úbody_posÚ_TYPE_BODY_POSITIONÚNonec              
   C  st   t | ddƒ}|dur(t|tƒr(z||ƒ W dS  ty' } ztdƒ|‚d}~ww |tu r0tdƒ‚tdt|ƒ› d�ƒ‚)zæ
    Attempt to rewind body to a certain position.
    Primarily used for request redirects and retries.

    :param body:
        File-like object that supports seek.

    :param int pos:
        Position to seek to in file.
    ÚseekNzAAn error occurred when rewinding request body for redirect/retry.zRUnable to record file position for rewinding request body during a redirect/retry.z1body_pos must be of type integer, instead it was Ú.)r9   r*   Úintr:   r   r   Ú
ValueErrorÚtype)r3   r=   Ú	body_seekÚer   r   r   r8   ¤   s&   ÿþ€ÿÿÿr8   c                   @  s   e Zd ZU ded< ded< dS )ÚChunksAndContentLengthztyping.Iterable[bytes] | NoneÚchunksz
int | NoneÚcontent_lengthN)r   r   r   Ú__annotations__r   r   r   r   rG   Â   s   
 rG   útyping.Any | NoneÚmethodr+   Ú	blocksizerB   c                   sØ   ˆdu rd}|  ¡ tvrd}nWd}nTtˆttfƒr%tˆƒf}t|d ƒ}nAtˆdƒr8d
‡ ‡fdd„}|ƒ }d}n.ztˆƒ}W n! t	y_   zt
ˆƒ}d}W n t	y\   t	dˆ›�ƒd‚w Y nw ˆf}|j}t||d	�S )aR  Takes the HTTP request method, body, and blocksize and
    transforms them into an iterable of chunks to pass to
    socket.sendall() and an optional 'Content-Length' header.

    A 'Content-Length' of 'None' indicates the length of the body
    can't be determined so should use 'Transfer-Encoding: chunked'
    for framing instead.
    Nr   Úreadr%   útyping.Iterable[bytes]c                  3  s8   � t ˆtjƒ} 	 ˆ ˆ ¡}|sd S | r| d¡}|V  q)NTzutf-8)r*   ÚioÚ
TextIOBaserN   r/   )r/   Ú	datablock©rM   r3   r   r   Úchunk_readableè   s   €

úz&body_to_chunks.<locals>.chunk_readablezO'body' must be a bytes-like object, file-like object, or iterable. Instead was )rH   rI   )r%   rO   )ÚupperÚ_METHODS_NOT_EXPECTING_BODYr*   r+   Úbytesr   ÚlenÚhasattrÚ
memoryviewÚ	TypeErrorÚiterÚnbytesrG   )r3   rL   rM   rH   rI   rT   Úmvr   rS   r   Úbody_to_chunksÇ   s@   

ÿÿýÿÿür_   )NNNNNN)r   r   r   r   r    r!   r"   r!   r#   r!   r$   r   r%   r&   )r3   r4   r5   r6   r%   r6   )r3   r<   r=   r>   r%   r?   )r3   rK   rL   r+   rM   rB   r%   rG   )(Ú
__future__r   rP   ÚtypingÚbase64r   Úenumr   Ú
exceptionsr   Úutilr   ÚTYPE_CHECKINGr	   ÚSKIP_HEADERÚ	frozensetÚSKIPPABLE_HEADERSr.   Ú
brotlicffiÚ_unused_module_brotliÚImportErrorÚbrotliÚcompressionr   Ú_unused_module_zstdÚ	zstandardr   r   r   rJ   ÚUnionrB   r>   rV   r2   r;   r8   Ú
NamedTuplerG   r_   r   r   r   r   Ú<module>   sd    ÿ€ÿÿ€û	ú
Q
