Skip to main content

Module multipart

Module multipart 

Available on crate features 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 Multipart stream.
InvalidMultipartBoundary
Rejection used when the Content-Type header has no usable boundary parameter: none, more than one, or one that cannot frame a body.
InvalidMultipartContentType
Rejection used when the Content-Type is not multipart/form-data (e.g. multipart/mixed or another media type entirely).
Multipart
Extractor for multipart/form-data request bodies.
MultipartConfig
Per-field size and part-count constraints for Multipart.
MultipartError
Error type returned while reading a Multipart field.

Enums§

MultipartRejection
Rejection type for the Multipart extractor.