pub struct Multipart { /* private fields */ }Expand description
Streaming multipart/form-data extractor. Parts arrive in wire order and
must be consumed sequentially; next_part discards
any unread remainder of the previous part. Requires
content-type: multipart/form-data with a valid boundary — anything else is
415 JC0415.
Single-consumer: the extractor takes ownership of the body, so extracting it twice in one handler is a programming error (500 on stream routes).
Implementations§
Source§impl Multipart
impl Multipart
Sourcepub fn from_buffered(content_type: &str, body: impl Into<Bytes>) -> Option<Self>
pub fn from_buffered(content_type: &str, body: impl Into<Bytes>) -> Option<Self>
Build a buffered Multipart from an already-read body and its
Content-Type header value, or None if the content type is not
multipart/form-data with a valid boundary.
The Multipart extractor (FromRequest) is the normal path and is
415 on a non-multipart request. This constructor exists for handlers
that must accept either a multipart upload or some other content type
on the same route (e.g. a CSV import endpoint whose generated success
probe posts an empty JSON body): take Headers + RawBody, then
Multipart::from_buffered when the type matches. The parsing is
identical to the extractor’s buffered path.
Sourcepub fn set_part_cap(&mut self, bytes: usize)
pub fn set_part_cap(&mut self, bytes: usize)
Per-part byte cap enforced by Part::bytes/Part::text
(default 8 MiB).