HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/urllib3/__pycache__/fields.cpython-310.pyc
o

;j1*�@s�ddlmZddlZddlZddlZejeefZ	eje	e
ee	fe
ee	effZ	ddd	d
�Zddd�Z
ddd�Zddd�Zddd�ZGdd�d�ZdS)�)�annotationsN�application/octet-stream�filename�
str | None�default�str�returncCs|rt�|�dp
|S|S)z�
    Guess the "Content-Type" of a file.

    :param filename:
        The filename to guess the "Content-Type" of using :mod:`mimetypes`.
    :param default:
        If no "Content-Type" can be guessed, default to `default`.
    r)�	mimetypesZ
guess_type)rr�r
�B/opt/saltstack/salt/lib/python3.10/site-packages/urllib3/fields.py�guess_content_typesr�name�value�_TYPE_FIELD_VALUEc	s�ddl}|jdtdd�t�t�r��d��t�fdd�d	D��s=|�d
��d�}z|�d�W|Stt	fy<Ynwt
j��d��|�d
�����S)a�
    Helper function to format and quote a single header parameter using the
    strategy defined in RFC 2231.

    Particularly useful for header parameters which might contain
    non-ASCII values, like file names. This follows
    `RFC 2388 Section 4.4 <https://tools.ietf.org/html/rfc2388#section-4.4>`_.

    :param name:
        The name of the parameter, a string expected to be ASCII only.
    :param value:
        The value of the parameter, provided as ``bytes`` or `str``.
    :returns:
        An RFC-2231-formatted unicode string.

    .. deprecated:: 2.0.0
        Will be removed in urllib3 v3.0. This is not valid for
        ``multipart/form-data`` header parameters.
    rNz�'format_header_param_rfc2231' is insecure, deprecated and will be removed in urllib3 v3.0. This is not valid for multipart/form-data header parameters.���
stacklevel�utf-8c3s�|]}|�vVqdS�Nr
)�.0�ch�rr
r�	<genexpr>@s�z.format_header_param_rfc2231.<locals>.<genexpr>z"\
�="�"�asciiz*=)
�warnings�warn�
FutureWarning�
isinstance�bytes�decode�any�encode�UnicodeEncodeError�UnicodeDecodeError�email�utils�encode_rfc2231)r
rr�resultr
rr�format_header_param_rfc2231s&�

��r*cCs6t|t�r
|�d�}|�dddd��}|�d|�d�S)a�
    Format and quote a single multipart header parameter.

    This follows the `WHATWG HTML Standard`_ as of 2021/06/10, matching
    the behavior of current browser and curl versions. Values are
    assumed to be UTF-8. The ``\n``, ``\r``, and ``"`` characters are
    percent encoded.

    .. _WHATWG HTML Standard:
        https://html.spec.whatwg.org/multipage/
        form-control-infrastructure.html#multipart-form-data

    :param name:
        The name of the parameter, an ASCII-only ``str``.
    :param value:
        The value of the parameter, a ``str`` or UTF-8 encoded
        ``bytes``.
    :returns:
        A string ``name="value"`` with the escaped value.

    .. versionchanged:: 2.0.0
        Matches the WHATWG HTML Standard as of 2021/06/10. Control
        characters are no longer percent encoded.

    .. versionchanged:: 2.0.0
        Renamed from ``format_header_param_html5`` and
        ``format_header_param``. The old names will be removed in
        urllib3 v3.0.
    rz%0Az%0Dz%22)�
�
�"rr)rr r!�	translate)r
rr
r
r�format_multipart_header_paramOs

r/cC�"ddl}|jdtdd�t||�S)��
    .. deprecated:: 2.0.0
        Renamed to :func:`format_multipart_header_param`. Will be
        removed in urllib3 v3.0.
    rNz~'format_header_param_html5' has been renamed to 'format_multipart_header_param'. The old name will be removed in urllib3 v3.0.rr�rrrr/�r
rrr
r
r�format_header_param_html5u��
r4cCr0)r1rNzx'format_header_param' has been renamed to 'format_multipart_header_param'. The old name will be removed in urllib3 v3.0.rrr2r3r
r
r�format_header_param�r5r6c@sdeZdZdZ			d#d$d
d�Ze	d%d&dd��Zd'dd�Zd(dd�Zd)dd�Z				d#d*d!d"�Z
dS)+�RequestFielda�
    A data container for request body parameters.

    :param name:
        The name of this request field. Must be unicode.
    :param data:
        The data/value body.
    :param filename:
        An optional filename of the request field. Must be unicode.
    :param headers:
        An optional dict-like object of headers to initially use for the field.

    .. versionchanged:: 2.0.0
        The ``header_formatter`` parameter is deprecated and will
        be removed in urllib3 v3.0.
    Nr
r�datarrr�headers�typing.Mapping[str, str] | None�header_formatter�5typing.Callable[[str, _TYPE_FIELD_VALUE], str] | NonecCsZ||_||_||_i|_|rt|�|_|dur(ddl}|jdtdd�||_dSt	|_dS)NrzSThe 'header_formatter' parameter is deprecated and will be removed in urllib3 v3.0.rr)
�_name�	_filenamer8r9�dictrrrr;r/)�selfr
r8rr9r;rr
r
r�__init__�s
�

zRequestField.__init__�	fieldnamer�_TYPE_FIELD_VALUE_TUPLErcCs`t|t�rt|�dkr|\}}}n|\}}t|�}nd}d}|}|||||d�}|j|d�|S)a�
        A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.

        Supports constructing :class:`~urllib3.fields.RequestField` from
        parameter of key/value strings AND key/filetuple. A filetuple is a
        (filename, data, MIME type) tuple where the MIME type is optional.
        For example::

            'foo': 'bar',
            'fakefile': ('foofile.txt', 'contents of foofile'),
            'realfile': ('barfile.txt', open('realfile').read()),
            'typedfile': ('bazfile.bin', open('bazfile').read(), 'image/jpeg'),
            'nonamefile': 'contents of nonamefile field',

        Field names and filenames must be unicode.
        �N)rr;)�content_type)r�tuple�lenr�make_multipart)�clsrBrr;rr8rEZ
request_paramr
r
r�from_tuples�s

�zRequestField.from_tuplescCs|�||�S)a�
        Override this method to change how each multipart header
        parameter is formatted. By default, this calls
        :func:`format_multipart_header_param`.

        :param name:
            The name of the parameter, an ASCII-only ``str``.
        :param value:
            The value of the parameter, a ``str`` or UTF-8 encoded
            ``bytes``.

        :meta public:
        )r;)r@r
rr
r
r�_render_part�szRequestField._render_part�header_parts�[dict[str, _TYPE_FIELD_VALUE | None] | typing.Sequence[tuple[str, _TYPE_FIELD_VALUE | None]]cCsNg}t|t�r|��}n|}|D]\}}|dur!|�|�||��qd�|�S)aO
        Helper function to format and quote a single header.

        Useful for single headers that are composed of multiple items. E.g.,
        'Content-Disposition' fields.

        :param header_parts:
            A sequence of (k, v) tuples or a :class:`dict` of (k, v) to format
            as `k1="v1"; k2="v2"; ...`.
        N�; )rr?�items�appendrK�join)r@rL�parts�iterabler
rr
r
r�
_render_partss

�
zRequestField._render_partscCs�g}gd�}|D]}|j�|d�r|�|�d|j|���q|j��D]\}}||vr8|r8|�|�d|���q$|�d�d�|�S)z=
        Renders the headers for this request field.
        )�Content-Disposition�Content-Type�Content-LocationFz: z
)r9�getrPrOrQ)r@�lines�	sort_keysZsort_key�header_nameZheader_valuer
r
r�render_headers#s��

zRequestField.render_headers�content_dispositionrE�content_location�Nonec	CsN|pdd�d|�d|jfd|jff�g�}||jd<||jd<||jd<d	S)
a�
        Makes this request field into a multipart request field.

        This method overrides "Content-Disposition", "Content-Type" and
        "Content-Location" headers to the request parameter.

        :param content_disposition:
            The 'Content-Disposition' of the request body. Defaults to 'form-data'
        :param content_type:
            The 'Content-Type' of the request body.
        :param content_location:
            The 'Content-Location' of the request body.

        z	form-datarN�r
rrUrVrWN)rQrTr=r>r9)r@r]rEr^r
r
rrH6s
���
	
zRequestField.make_multipart)NNN)
r
rr8rrrr9r:r;r<r)rBrrrCr;r<rr7�r
rrrrr)rLrMrr)rr)r]rrErr^rrr_)�__name__�
__module__�__qualname__�__doc__rA�classmethodrJrKrTr\rHr
r
r
rr7�s ��
,

�r7)r)rrrrrrra)�
__future__r�email.utilsr&r	�typing�Unionrr rrFrCrr*r/r4r6r7r
r
r
r�<module>s$
���

0
&