Python multipart/form-data parser¶
This module provides a fast incremental non-blocking parser for
multipart/form-data
[HTML5, RFC7578], as well as blocking alternatives for
easier use in WSGI or CGI applications:
SansIO parser: Fast SansIO (incremental, non-blocking) parser suitable for ASGI, asyncio and other IO, time or memory constrained environments.
Streaming parser: Blocking parser that reads from a stream and yields memory- or disk-buffered
MultipartPart
instances.WSGI helper: High-level functions and containers for WSGI or CGI applications with support for both multipart and urlencoded form submissions.
Features and Scope¶
Pure python single file module with no dependencies.
Optimized for both blocking and non-blocking applications.
100% test coverage with test data from actual browsers and HTTP clients.
High throughput and low latency (see benchmarks).
Predictable memory and disk resource consumption via fine grained limits.
Strict mode: Spent less time parsing malicious or broken inputs.
Scope: All parsers in this module implement multipart/form-data
as defined by HTML5
and RFC7578, supporting all modern browsers or HTTP clients in use today.
Legacy browsers (e.g. IE6) are supported to some degree, but only if the
required workarounds do not impact performance or security. In detail this means:
Just
multipart/form-data
, not suitable for email parsing.No
multipart/mixed
support (deprecated in RFC7578).No
base64
orquoted-printable
transfer encoding (deprecated in RFC7578).No
encoded-word
orname=_charset_
encoding markers (deprecated in HTML5).No support for clearly broken clients (e.g. invalid line breaks or headers).
Installation¶
pip install multipart
Table of Content¶
License¶
Copyright (c) 2010-2024, Marcel Hellkamp
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.