Files
intellecton/venv/lib/python3.12/site-packages/urllib3/__pycache__/fields.cpython-312.pyc
T

161 lines
12 KiB
Plaintext
Raw Normal View History

Ë
j1*ãóÎddlmZddlZddlZddlZej eefZ ej e e
ee fe
ee effZ d
d dZ d dZ
d dZd dZd dZGdd «Zy)
é)Ú annotationsNcóB|rtj|«dxs|S|S)
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)ÚfilenameÚdefaults úQ/home/antigravity/intellecton/venv/lib/python3.12/site-packages/urllib3/fields.pyÚguess_content_typer
s'ñÜ×# HÓ-¨aÑ;°GÐ €NócóZddl}|jdtd¬«tt«rj d«Št
ˆfddD««s|d ‰d
} |jd «|Stjjd«Š|d ŠS#ttf$rYŒ:wxYw)

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-8c3ó&K|]}|vŒ
y­w©)Ú.0ÚchÚvalues €r ú <genexpr>z.format_header_param_rfc2231.<locals>.<genexpr>@søèø€Ò/˜rˆrUŒ{Ñ/ùsƒz"\
ú="úasciiz*=)
ÚwarningsÚwarnÚ
FutureWarningÚ
isinstanceÚbytesÚdecodeÚanyÚencodeÚUnicodeEncodeErrorÚUnicodeDecodeErrorÚemailÚutilsÚencode_rfc2231)ÚnamerrÚresults ` r Úformat_header_param_rfc2231r*ø€ó(à ‡M Øð ôôÔØ ˜WÓä Ó/ YÔ ˜E˜7 !Ð$ˆð Ø M‰M˜ ˆ K‰K× & u¨gÓ 6€E؈fBu €Eà €Løô#Ô$6Ð Ù ð úsÁBÂB*Â)B*có~t|t«r|jd«}|jddddœ«}|d|dS)
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)rrr Ú translate)r(rs r Úformat_multipart_header_paramr0OsFô<ÔØ ˜WÓð
O‰O ¨E°uÑ >€E؈V2eW˜ Ðr cóRddl}|jdtd¬«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.r
r©rrrr0©r(rrs r Úformat_header_param_html5r5uó4ó à ‡M Øð ôô ¨uÓ 5r cóRddl}|jdtd¬«t||«S)r2rNzx'format_header_param' has been renamed to 'format_multipart_header_param'. The old name will be removed in urllib3 v3.0.r
rr3r4s r Úformat_header_paramr8r6r có”eZdZdZ d d
dZe d d d«Zd
dZ ddZddZ d ddZ
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.
.. versionchanged:: 2.0.0
The ``header_formatter`` parameter is deprecated and will
be removed in urllib3 v3.0.
NcóÂ||_||_||_i|_|rt |«|_|$ddl}|j
dtd¬«||_yt|_y)NrzSThe 'header_formatter' parameter is deprecated and will be removed in urllib3 v3.0.r
r)
Ú_nameÚ _filenameÚdataÚheadersÚdictrrrÚheader_formatterr0)Úselfr(r>rr?rArs r Ú__init__zRequestField.__init__«seðˆŒ
،؈Œ Ø.0ˆŒ Ù Ü ›=ˆDŒLà Ð à M‰MðØð
ô
ð %5ˆ !ä$Aˆ !r cóºt|t«r&t|«dk(r|\}}}n|\}}t|«}nd}d}|}|||||¬«}|j |¬«|S)
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)rrA)Ú content_type)rÚtupleÚlenr
Úmake_multipart)ÚclsÚ fieldnamerrArr>rFÚ
request_params r Ú from_tupleszRequestField.from_tuplesÇstô6 eœUÔ 5‹z˜Ø/4Ñ,˜ à!&˜$Ü1°(Ó;‘ àˆH؈L؈DáØ t hÐAQô
ˆ
ð ×$°,ÐÐr có&|j||«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:
)rA)rBr(rs r Ú _render_partzRequestField._render_partôsð×$ T¨5Ó1r cóÊg}t|t«r|j«}n|}|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"; ...`.
ú; )rr@ÚitemsÚappendrOÚjoin)rBÚ header_partsÚpartsÚiterabler(rs r Ú
_render_partszRequestField._render_partssið&ˆÜ l¤DÔ +‰Hà#ˆHà =‰KˆDÑ Ø ˜T×.¨t°UÓy‰y˜ÓÐr có`g}gd¢}|D]B}|jj|d«sŒ |j|d|j|«ŒD|jj«D]#\}}||vsŒ |sŒ|j|d|«Œ%|jd«dj |«S)z=
Renders the headers for this request field.
)úContent-Dispositionú Content-TypeúContent-LocationFz: z
)r?ÚgetrSrRrT)rBÚlinesÚ sort_keysÚsort_keyÚ header_nameÚ header_values r Úrender_headerszRequestField.render_headers#s¸ðˆâOˆ Ø FˆHØ|‰|×Ñ ¨%Õ  ˜z¨¨D¯L©L¸Ñ,BÐ+CÐ Fð*.¯©×);Ñ);Ó)=ò CÑ %ˆK˜Ø Ø—LL K °<°.Ð!AÕ Cð
 Ø{‰{˜!r c óä|xsddjd|jd|jfd|jff«g«z}||jd<||jd<||jd<y )

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.