These classes encapsulate a request parameters or fields and are suitable for
passing to request()
.
A data container for request body parameters.
name – The name of this request field. Must be unicode.
data – The data/value body.
filename – An optional filename of the request field. Must be unicode.
headers – An optional dict-like object of headers to initially use for the field.
Changed in version 2.0.0: The header_formatter
parameter is deprecated and will
be removed in urllib3 v2.1.0.
Override this method to change how each multipart header
parameter is formatted. By default, this calls
format_multipart_header_param()
.
name – The name of the parameter, an ASCII-only str
.
value – The value of the parameter, a str
or UTF-8 encoded
bytes
.
A RequestField
factory from old-style tuple parameters.
Supports constructing 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.
Makes this request field into a multipart request field.
This method overrides “Content-Disposition”, “Content-Type” and “Content-Location” headers to the request parameter.
content_disposition – The ‘Content-Disposition’ of the request body. Defaults to ‘form-data’
content_type – The ‘Content-Type’ of the request body.
content_location – The ‘Content-Location’ of the request body.