8f!ddlmZddlZddlZddlZddlmZddZdZ dd d Z e d e 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 z/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/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 `_. :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 z.format_header_param_rfc2231..+s'//rrU{//////rz"\ =""asciiz*=) isinstancer binary_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 r/JsE  W   2 ))"--   r cfd}tjddD}|||}|S)Nc:|dS)Nr)group)matchneedles_and_replacementss r replacerz#_replace_multiple..replacerSs' A77r|c6g|]}tj|Sr)reescape)rneedles r z%_replace_multiple..Ws"SSS29V$$SSSr)r9compilejoinkeyssub)rr5r6patternr's ` r _replace_multiplerBRst88888j SS3K3P3P3R3RSSSTTG[[5 ) )F Mrct|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 dZ 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. :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_partss lD ) ) ,#))++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_key header_name header_values r render_headerszRequestField.render_headerssOOO ! M MH|%00 M (((DL4J4JKLLL)-););)=)= J J %K)++JLLkkk<rdrIrJ)rOcontent_dispositionrScontent_locations r rVzRequestField.make_multiparts/B.Q\ *+ *+++uzz""tz*[$.,IJ 0 0  +++(4 ^$+; '(((r)NNN) __name__ __module__ __qualname____doc__rErP classmethodrZr\rdrorVrrr rGrG~s(2 1111 rs)&&&&&&     '''V%h''   &&&80T<T<T<T<T<6T<T<T<T<T