module documentation

Undocumented

Class MultiPartProducer :class:`MultiPartProducer` takes parameters for a HTTP request and produces bytes in multipart/form-data format defined in :rfc:`2388` and :rfc:`2046`.
Constant CRLF Undocumented
Class _Header `_Header` This class is a tiny wrapper that produces request headers. We can't use standard python header class because it encodes unicode fields using =? bla bla ?= encoding, which is correct, but no one in HTTP world expects that, everyone wants utf-8 raw bytes.
Class _LengthConsumer `_LengthConsumer` is used to calculate the length of the multi-part request. The easiest way to do that is to consume all the fields, but instead writing them to the string just accumulate the request length.
Function _converted Undocumented
Function _enforce_unicode This function enforces the strings passed to be unicode, so we won't need to guess what's the encoding of the binary strings passed in. If someone needs to pass the binary string, use BytesIO and wrap it with `FileBodyProducer`.
Function _escape This function prevents header values from corrupting the request, a newline in the file name parameter makes form-data request unreadable for majority of parsers.
Function _sorted_by_type Sorts params so that strings are placed before files.

Undocumented

Value
b'''\r
'''
def _converted(fields): (source)

Undocumented

def _enforce_unicode(value): (source)

This function enforces the strings passed to be unicode, so we won't need to guess what's the encoding of the binary strings passed in. If someone needs to pass the binary string, use BytesIO and wrap it with `FileBodyProducer`.

def _escape(value): (source)

This function prevents header values from corrupting the request, a newline in the file name parameter makes form-data request unreadable for majority of parsers.

def _sorted_by_type(fields): (source)

Sorts params so that strings are placed before files. That makes a request more readable, as generally files are bigger. It also provides deterministic order of fields what is easier for testing.