Module multipart
http and multipart and std only.Expand description
Server-side multipart/form-data extractor.
Use Multipart as a handler argument to iterate over form fields. See
the http_multipart example for usage.
Spec references (vendored under rama-http/specifications/):
- RFC 7578 —
multipart/form-data - RFC 2046 — MIME Part Two: Media Types (boundary framing)
- RFC 6266 —
Content-Disposition
Built on the sans-IO parser in crate::protocols::multipart, which a
proxy can use directly to rewrite a form as it streams by.
The body is parsed as it streams in and field data is handed out as slices of the body chunks, without buffering or copying it.
Framing is strict wherever leniency would leave room for two parsers to read one body differently: lines end in CRLF, header lines are not folded, a line opening with the delimiter is a delimiter, and a body has to reach its close delimiter. Transport padding after a boundary is accepted, the preamble and epilogue are ignored (RFC 2046 §5.1.1).
Names and file names are UTF-8, taken from a token or quoted string as
sent: percent-encoding and RFC 2047 encoded-words are not decoded, and
filename* is ignored (RFC 7578 §4.2). A file name is client input and can
hold a path, never use it as one.
Structs§
- Field
- A single field inside a
Multipartstream. - Invalid
Multipart Boundary - Rejection used when the
Content-Typeheader has no usable boundary parameter: none, more than one, or one that cannot frame a body. - Invalid
Multipart Content Type - Rejection used when the
Content-Typeis notmultipart/form-data(e.g.multipart/mixedor another media type entirely). - Multipart
- Extractor for
multipart/form-datarequest bodies. - Multipart
Config - Per-field size and part-count constraints for
Multipart. - Multipart
Error - Error type returned while reading a
Multipartfield.
Enums§
- Multipart
Rejection - Rejection type for the
Multipartextractor.