Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/urllib3/__pycache__/fields.cpython-311.pyc



]j!ddlmZddlZddlZddlZddlmZddZdZ	dd	d
Z
e
deddDd
Z
dZeZGddeZdS))absolute_importN)sixapplication/octet-streamcB|rtj|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)	mimetypes
guess_type)filenamedefaults  E/opt/imunify360/venv/lib64/python3.11/site-packages/urllib3/fields.pyguess_content_typer

s,<#H--a0;G;Ncttjrdt	fddDs7|dd}	|d|S#ttf$rYnwxYwtjrdtj
d|dtjrdS)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``.
    :ret:
        An RFC-2231-formatted unicode string.
    utf-8c3 K|]}|vV	dSN).0chvalues  r	<genexpr>z.format_header_param_rfc2231.<locals>.<genexpr>+s'//rrU{//////rz"\
=""asciiz*=)
isinstancerbinary_typedecodeanyencodeUnicodeEncodeErrorUnicodeDecodeErrorPY2emailutilsencode_rfc2231)namerresults ` rformat_header_param_rfc2231r(s
 %))&W%%////Y/////#ttUUU+	MM'"""M#$67			D	
w&W%%
K&&ug66Eee$E
w&W%%LsA,,B?Bz%22z\\)r\cfi|].}|dvtj|d|/S))z%{:02X})runichrformat)rccs  r
<dictcomp>r/JsE
W	
2
))"--r cfd}tjddD}|||}|S)Nc:|dS)Nr)group)matchneedles_and_replacementss rreplacerz#_replace_multiple.<locals>.replacerSs'A77r|c6g|]}tj|Sr)reescape)rneedles  r
<listcomp>z%_replace_multiple.<locals>.<listcomp>Ws"SSS29V$$SSSr)r9compilejoinkeyssub)rr5r6patternr's `   r_replace_multiplerBRst88888j		SS3K3P3P3R3RSSSTTG[[5
)
)FMrct|tjr|d}t	|t
}|d|dS)a
    Helper function to format and quote a single header parameter using the
    HTML5 strategy.

    Particularly useful for header parameters which might contain
    non-ASCII values, like file names. This follows the `HTML5 Working Draft
    Section 4.10.22.7`_ and matches the behavior of curl and modern browsers.

    .. _HTML5 Working Draft Section 4.10.22.7:
        https://w3c.github.io/html/sec-forms.html#multipart-form-data

    :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``.
    :ret:
        A unicode string, stripped of troublesome characters.
    rrr)rrrrrB_HTML5_REPLACEMENTS)r&rs  rformat_header_param_html5rE_sL&%))&W%%e%899Euuu%%rcVeZdZdZddefdZeefdZdZdZ	dZ
	d	dZdS)
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.
    :param header_formatter:
        An optional callable that is used to encode and format the headers. By
        default, this is :func:`format_header_param_html5`.
    Ncx||_||_||_i|_|rt	||_||_dSr)_name	_filenamedataheadersdictheader_formatter)selfr&rKr
rLrNs      r__init__zRequestField.__init__sC
!		)==DL 0rct|tr/t|dkr|\}}}n|\}}t|}nd}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
rN)content_type)rtuplelenr
make_multipart)cls	fieldnamerrNr
rKrS
request_params        rfrom_tupleszRequestField.from_tupless$eU##		5zzQ/4,$!&$1(;;HLDthAQ



	$$,$???rc.|||S)aI
        Overridable helper function to format a single header parameter. By
        default, this calls ``self.header_formatter``.

        :param name:
            The name of the parameter, a string expected to be ASCII only.
        :param value:
            The value of the parameter, provided as a unicode string.
        )rN)rOr&rs   r_render_partzRequestField._render_parts$$T5111rcg}|}t|tr|}|D]0\}}|)||||1d|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; )rrMitemsappendr\r>)rOheader_partspartsiterabler&rs      r
_render_partszRequestField._render_partsslD))	,#))++H#	=	=KD% T..tU;;<<<zz%   rcjg}gd}|D]B}|j|dr%||d|j|C|jD]%\}}||vr|r||d|&|dd|S)z=
        Renders the headers for this request field.
        )Content-DispositionContent-TypeContent-LocationFz: z
)rLgetr`r_r>)rOlines	sort_keyssort_keyheader_nameheader_values      rrender_headerszRequestField.render_headerssOOO	!	M	MH|%00
M(((DL4J4JKLLL)-););)=)=	J	J%K)++JLLkkk<<!HIII
W||E"""rc|pd|jd<|jdxxdd|d|jfd|jffgz
cc<||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_type:
            The 'Content-Type' of the request body.
        :param content_location:
            The 'Content-Location' of the request body.

        z	form-datarfr^r&r
rgrhN)rLr>rdrIrJ)rOcontent_dispositionrScontent_locations    rrVzRequestField.make_multiparts/B.Q\*+*+++uzz""tz*[$.,IJ
0
0
	
+++(4^$+;'(((r)NNN)__name__
__module____qualname____doc__rErPclassmethodrZr\rdrorVrrrrGrG~s(2
1111 <U!!![!F222!!!,###(MQ<<<<<<rrG)r)
__future__remail.utilsr#rr9packagesrr
r(rDupdaterangerBrEformat_header_paramobjectrGrrr<module>rs)&&&&&&				'''V%h''


&&&80T<T<T<T<T<6T<T<T<T<T<r
Back to Directory File Manager