o
    ûÞhM*  ã                   @  sœ   d dl mZ d dlZd dlZd dlZejeef Z	eje	e
ee	f e
ee	ef f Z	ddd	d
„Zddd„Zddd„Zddd„Zddd„ZG dd„ dƒZdS )é    )ÚannotationsNúapplication/octet-streamÚfilenameú
str | NoneÚdefaultÚstrÚreturnc                 C  s   | rt  | ¡d p
|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   )Ú	mimetypesÚ
guess_type)r   r   © r   úN/var/www/html/premium_crap/venv/lib/python3.10/site-packages/urllib3/fields.pyÚguess_content_type   s   r   ÚnameÚvalueÚ_TYPE_FIELD_VALUEc              	     sš   ddl }|jdtdd� tˆ tƒrˆ  d¡‰ t‡ fdd„d	D ƒƒs=| › d
ˆ › d�}z| d¡ W |S  tt	fy<   Y nw t
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 v2.1.0. This is not valid for
        ``multipart/form-data`` header parameters.
    r   Nz�'format_header_param_rfc2231' is deprecated and will be removed in urllib3 v2.1.0. This is not valid for multipart/form-data header parameters.é   ©Ú
stacklevelúutf-8c                 3  s   � | ]}|ˆ v V  qd S ©Nr   )Ú.0Úch©r   r   r   Ú	<genexpr>@   s   € z.format_header_param_rfc2231.<locals>.<genexpr>z"\
ú="ú"Úasciiz*=)ÚwarningsÚwarnÚDeprecationWarningÚ
isinstanceÚbytesÚdecodeÚanyÚencodeÚUnicodeEncodeErrorÚUnicodeDecodeErrorÚemailÚutilsÚencode_rfc2231)r   r   r   Úresultr   r   r   Úformat_header_param_rfc2231   s&   û

ýÿr+   c                 C  s6   t |tƒr
| d¡}| ddddœ¡}| › 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 v2.1.0.
    r   z%0Az%0Dz%22)é
   é   é"   r   r   )r    r!   r"   Ú	translate)r   r   r   r   r   Úformat_multipart_header_paramO   s   

r0   c                 C  ó"   ddl }|jdtdd� t| |ƒS )ú„
    .. deprecated:: 2.0.0
        Renamed to :func:`format_multipart_header_param`. Will be
        removed in urllib3 v2.1.0.
    r   Nz€'format_header_param_html5' has been renamed to 'format_multipart_header_param'. The old name will be removed in urllib3 v2.1.0.r   r   ©r   r   r   r0   ©r   r   r   r   r   r   Úformat_header_param_html5u   ó   û
r5   c                 C  r1   )r2   r   Nzz'format_header_param' has been renamed to 'format_multipart_header_param'. The old name will be removed in urllib3 v2.1.0.r   r   r3   r4   r   r   r   Úformat_header_param‡   r6   r7   c                   @  sd   e Zd ZdZ			d#d$dd„Ze	d%d&dd„ƒZd'dd„Zd(dd„Zd)dd„Z				d#d*d!d"„Z
dS )+Ú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 v2.1.0.
    Nr   r   Údatar   r   r   Úheadersútyping.Mapping[str, str] | NoneÚheader_formatterú5typing.Callable[[str, _TYPE_FIELD_VALUE], str] | Nonec                 C  sZ   || _ || _|| _i | _|rt|ƒ| _|d ur(dd l}|jdtdd� || _d S t	| _d S )Nr   zUThe 'header_formatter' parameter is deprecated and will be removed in urllib3 v2.1.0.r   r   )
Ú_nameÚ	_filenamer9   r:   Údictr   r   r   r<   r0   )Úselfr   r9   r   r:   r<   r   r   r   r   Ú__init__«   s   
ü

zRequestField.__init__Ú	fieldnamer   Ú_TYPE_FIELD_VALUE_TUPLEr   c                 C  s`   t |tƒrt|ƒdkr|\}}}n|\}}t|ƒ}nd}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)r   r<   )Úcontent_type)r    ÚtupleÚlenr   Úmake_multipart)ÚclsrC   r   r<   r   r9   rF   Úrequest_paramr   r   r   Úfrom_tuplesÇ   s   

ÿzRequestField.from_tuplesc                 C  s   |   ||¡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<   )rA   r   r   r   r   r   Ú_render_partô   s   zRequestField._render_partÚheader_partsú[dict[str, _TYPE_FIELD_VALUE | None] | typing.Sequence[tuple[str, _TYPE_FIELD_VALUE | None]]c                 C  sN   g }t |tƒr| ¡ }n|}|D ]\}}|dur!| |  ||¡¡ qd |¡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ú; )r    r@   ÚitemsÚappendrM   Újoin)rA   rN   ÚpartsÚiterabler   r   r   r   r   Ú_render_parts  s   

€
zRequestField._render_partsc                 C  s†   g }g d¢}|D ]}| j  |d¡r| |› d| j | › �¡ q| j  ¡ D ]\}}||vr8|r8| |› d|› �¡ q$| d¡ d |¡S )z=
        Renders the headers for this request field.
        )úContent-DispositionúContent-TypeúContent-LocationFz: z
)r:   ÚgetrR   rQ   rS   )rA   ÚlinesÚ	sort_keysÚsort_keyÚheader_nameÚheader_valuer   r   r   Úrender_headers#  s   €€

zRequestField.render_headersÚcontent_dispositionrF   Úcontent_locationÚNonec              	   C  sN   |pdd  d|  d| jfd| jff¡g¡ }|| jd< || jd< || jd< 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-datarP   Ú r   r   rW   rX   rY   N)rS   rV   r>   r?   r:   )rA   ra   rF   rb   r   r   r   rI   6  s   
ÿþÿ
	
zRequestField.make_multipart)NNN)
r   r   r9   r   r   r   r:   r;   r<   r=   r   )rC   r   r   rD   r<   r=   r   r8   ©r   r   r   r   r   r   )rN   rO   r   r   )r   r   )ra   r   rF   r   rb   r   r   rc   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rB   ÚclassmethodrL   rM   rV   r`   rI   r   r   r   r   r8   ™   s     úü
,

ür8   )r   )r   r   r   r   r   r   re   )Ú
__future__r   Úemail.utilsr'   r	   ÚtypingÚUnionr   r!   r   rG   rD   r   r+   r0   r5   r7   r8   r   r   r   r   Ú<module>   s$    
þÿÿ

0
&
