class documentation

class RequestField(object): (source)

View In Hierarchy

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`.

Class Method from_tuples A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters.
Method __init__ Undocumented
Method make_multipart Makes this request field into a multipart request field.
Method render_headers Renders the headers for this request field.
Instance Variable data Undocumented
Instance Variable header_formatter Undocumented
Instance Variable headers Undocumented
Method _render_part Overridable helper function to format a single header parameter. By default, this calls ``self.header_formatter``.
Method _render_parts Helper function to format and quote a single header.
Instance Variable _filename Undocumented
Instance Variable _name Undocumented
@classmethod
def from_tuples(cls, fieldname, value, header_formatter=format_header_param_html5): (source)

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.

def __init__(self, name, data, filename=None, headers=None, header_formatter=format_header_param_html5): (source)

Undocumented

def make_multipart(self, content_disposition=None, content_type=None, content_location=None): (source)

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.

def render_headers(self): (source)

Renders the headers for this request field.

Undocumented

header_formatter = (source)

Undocumented

Undocumented

def _render_part(self, name, value): (source)

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.

def _render_parts(self, header_parts): (source)

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"; ...`.

_filename = (source)

Undocumented

Undocumented