HOME


Mini Shell 1.0
DIR: /usr/lib/python3/dist-packages/urllib3/util/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/urllib3/util/__pycache__/request.cpython-312.pyc
�

�g����UddlmZddlZddlZddlmZddlmZddlm	Z	ddl
mZejrdd	l
mZd
Zegd��ZdZ		ddlZed
z
Z	ddlZedz
ZGd�de�Zej4Zded<ej:eefZhd�Z 						d													dd�Z!						dd�Z"dd�Z#Gd�dejH�Z%								dd�Z&y#e$rddlZY��wxYw#e$rY��wxYw#e$rY��wxYw)�)�annotationsN)�	b64encode)�Enum�)�UnrewindableBodyError�)�to_bytes)�Finalz@@@SKIP_HEADER@@@)�accept-encoding�host�
user-agentzgzip,deflatez,brz,zstdc��eZdZdZy)�_TYPE_FAILEDTELLrN)�__name__�
__module__�__qualname__�token���6/usr/lib/python3/dist-packages/urllib3/util/request.pyrr's��
�ErrzFinal[_TYPE_FAILEDTELL]�_FAILEDTELL>�GET�HEAD�TRACE�DELETE�CONNECT�OPTIONSc�t�i}|r>t|t�rn(t|t�rdj|�}nt}||d<|r||d<|rd|d<|r.dt|j
d��j���|d<|r.dt|j
d��j���|d	<|rd
|d<|S)a�
    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 either the ``brotli`` or
        ``brotlicffi`` package is installed 'gzip,deflate,br' is used instead.
        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'}
    �,rr
z
keep-alive�
connectionzBasic zlatin-1�
authorizationzproxy-authorizationzno-cachez
cache-control)�
isinstance�str�list�join�ACCEPT_ENCODINGr�encode�decode)�
keep_alive�accept_encoding�
user_agent�
basic_auth�proxy_basic_auth�
disable_cache�headerss       r�make_headersr07s���^!�G���o�s�+��
���
.�!�h�h��7�O�-�O�%4��!�"�� *����� ,������Y�z�0�0��;�<�C�C�E�F�G�	��	
���Y�/�6�6�y�A�B�I�I�K�L�M�	�!�	
��#-��� ��Nrc��|�t||�|St|dd��	|j�}|S|S#t$r
t}Y|SwxYw)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�getattrr2�OSErrorr)�body�poss  r�set_file_positionr8�sc�����D�#���J�
��v�t�	$�	0�	��)�)�+�C��J�3�J���	��C��J�	�s�3�A�Ac���t|dd�}|�t|t�r
	||�y|t
urt	d��t
dt|��d���#t$r}t	d�|�d}~wwxYw)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 �.)r4r"�intr5rr�
ValueError�type)r6�body_pos�	body_seek�es    rr3r3�s�����f�d�+�I����H�c�!:�	��h��

�[�	 �#�
4�
�	
�
�?��X��?O�q�Q�
�	
���	�'�S���
��	�s�A�	A/�A*�*A/c�"�eZdZUded<ded<y)�ChunksAndContentLengthztyping.Iterable[bytes] | None�chunksz
int | None�content_lengthN)rrr�__annotations__rrrrCrC�s��)�)��rrCc������d}|j�tvrd}nld}nit�ttf�rt��f}t
|d�}n8t�d�rd��fd�}|�}d}n	t��}�f}|j}t||��S#t$r.	t��}d}n#t$rtd����d�wxYwY�CwxYw)aRTakes 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�readc3��K�t�tj�}	�j��}|sy|r|j	d�}|���,�w)Nz
iso-8859-1)r"�io�
TextIOBaserHr')r'�	datablock�	blocksizer6s  ��r�chunk_readablez&body_to_chunks.<locals>.chunk_readable�sK�������b�m�m�4�F�� �I�I�i�0�	� ��� )� 0� 0�� >�I���
�s�AAzO'body' must be a bytes-like object, file-like object, or iterable. Instead was )rDrE)�returnztyping.Iterable[bytes])
�upper�_METHODS_NOT_EXPECTING_BODYr"r#�bytesr	�len�hasattr�
memoryview�nbytes�	TypeError�iterrC)r6�methodrMrDrErN�mvs` `    r�body_to_chunksr[�s����$�|����<�<�>�!<�<��N�!�N�
�D�3��,�	'��4�.�"���V�A�Y���
��v�	�		 � �!����	'��D�!�B��W�F��Y�Y�N�!���O�O���		�
��d���!%����
��8�8<�x�A����
���			�s*�2B�	C�#
B1�0C�1C
�
C�C)NNNNNN)r)�bool | Noner*zbool | list[str] | str | Noner+�
str | Noner,r]r-r]r.r\rOzdict[str, str])r6z
typing.Anyr7�_TYPE_BODY_POSITION | NonerOr^)r6ztyping.IO[typing.AnyStr]r?�_TYPE_BODY_POSITIONrO�None)r6ztyping.Any | NonerYr#rMr<rOrC)'�
__future__rrJ�typing�base64r�enumr�
exceptionsr�utilr	�
TYPE_CHECKING�typing_extensionsr
�SKIP_HEADER�	frozenset�SKIPPABLE_HEADERSr&�
brotlicffi�_unused_module_brotli�ImportError�brotli�	zstandard�_unused_module_zstdrrrrF�Unionr<r_rQr0r8r3�
NamedTuplerCr[rrr�<module>rts���"�	�
���.��	���'�"���G�H�� ���/�2��u��O��+��w��O��t��(8�'=�'=��
$�=��l�l�3�(8�#8�9��W��#�59�!�!�#'�!%�
L��L�2�L��L��	L�
!�L��
L��L�^�
��5����(
�<�V�.�.��
CP�
�CP�%(�CP�58�CP��CP��I�/�.�/���	��	���	��	�s<�
C�C0�	C"�C%�!C"�"C%�%C-�,C-�0C8�7C8