\h! ddlmZddlZddlZddlZddlmZddZdZ ddd Z e je dd Dcic](}|d vr"ej|d j|*c}d ZdZeZGddeZycc}w))absolute_importN)sixcB|rtj|dxs|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 ]/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pip/_vendor/urllib3/fields.pyguess_content_typer s'##H-a0;G; Ncttjrjdt fddDs|dd} |j d|Stjrj dtjjd|dtjrjdS#t tf$rY|wxYw)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|]}|v ywN).0chvalues r z.format_header_param_rfc2231..+s/rrU{/sz"\ =""asciiz*=) isinstancer binary_typedecodeanyencodeUnicodeEncodeErrorUnicodeDecodeErrorPY2emailutilsencode_rfc2231)namerresults ` r format_header_param_rfc2231r's %) W% /Y/ /#U+  MM' "M ww W% KK & &ug 6Ee $E ww W% L!#$67   s CCCz%22z\\)r\ )z%{:02X}c fd}tjdjjDcgc]}tj|c}}|j ||}|Scc}w)Nc,|jdS)Nr)group)matchneedles_and_replacementss r replacerz#_replace_multiple..replacerSs' A77r |)recompilejoinkeysescapesub)rr/r0needlepatternr&s ` r _replace_multipler:Rs_8jj 3K3P3P3RS299V$STG[[5 )F M TsA. ct|tjr|jd}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)rrrrr:_HTML5_REPLACEMENTS)r%rs r format_header_param_html5r=_s8&%) W% e%8 9Eu %%r cNeZdZdZddefdZeefdZdZdZ dZ d dZ y) 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`. Ncn||_||_||_i|_|rt ||_||_yr)_name _filenamedataheadersdictheader_formatter)selfr%rCr rDrFs r __init__zRequestField.__init__s6 !  =DL 0r ct|tr&t|dk(r|\}}}n|\}}t|}nd}d}|}|||||}|j ||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 rF) content_type)rtuplelenr make_multipart)cls fieldnamerrFr rCrK request_params r from_tupleszRequestField.from_tuplesst$ eU #5zQ/4,$ !&$1(; HLD thAQ  $$,$?r c&|j||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. )rF)rGr%rs r _render_partzRequestField._render_parts$$T511r cg}|}t|tr|j}|D])\}}| |j|j ||+dj |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"; ...`. ; )rrEitemsappendrTr4)rG header_partspartsiterabler%rs r _render_partszRequestField._render_partssi lD )#))+H# =KD%  T..tU;< =zz%  r c`g}gd}|D]B}|jj|ds |j|d|j|D|jjD]#\}}||vs |s|j|d|%|jddj |S)z= Renders the headers for this request field. )Content-Disposition Content-TypeContent-LocationFz: z )rDgetrXrWr4)rGlines sort_keyssort_key header_name header_values r render_headerszRequestField.render_headerssO ! MH||%0 (DLL4JKL M*.););)= J %K)+LLkr{s&  'Vh'  W   2 ))"-- &80T<6T