pub struct MultipartFormData;Expand description
Parser for multipart/form-data bodies.
Decodes a body into its parts using the boundary declared by the request
Content-Type header, without depending on any external multipart crate.
Implementations§
Source§impl MultipartFormData
Implementation for MultipartFormData.
impl MultipartFormData
Implementation for MultipartFormData.
Sourcepub fn get_boundary<C>(content_type: C) -> Option<String>
pub fn get_boundary<C>(content_type: C) -> Option<String>
Reads the boundary parameter out of a multipart/form-data content type.
The parameter is matched case-insensitively and accepts both a quoted and
a bare value, so the clients that emit boundary="abc" and the clients
that emit boundary=abc are both accepted. A parameter that carries no
= is skipped rather than aborting the scan.
§Arguments
C- The content type header value, which requires theAsRef<str>bound.
§Returns
Option<MultipartFormDataBoundary>- The declared boundary, orNonewhen absent.
Sourcepub fn is_form_data<C>(content_type: C) -> bool
pub fn is_form_data<C>(content_type: C) -> bool
Sourcepub fn parse<B>(body: B, boundary: &str) -> Option<Vec<BodyPart>>
pub fn parse<B>(body: B, boundary: &str) -> Option<Vec<BodyPart>>
Decodes every part of a multipart/form-data body.
A body that carries no declared boundary, a body whose final boundary is
not the closing one, and a part that declares no name all yield None.
§Arguments
B- The raw request body, which requires theAsRef<[u8]>bound.&str- The declared boundary, without its leading dash pair.
§Returns
Option<MultipartFormDataParts>- The decoded parts, orNonewhen malformed.
Sourcepub fn try_get_part<K>(parts: &[BodyPart], name: K) -> Option<&BodyPart>
pub fn try_get_part<K>(parts: &[BodyPart], name: K) -> Option<&BodyPart>
Sourcepub fn try_get_part_text<K>(parts: &[BodyPart], name: K) -> Option<String>
pub fn try_get_part_text<K>(parts: &[BodyPart], name: K) -> Option<String>
Tries to get a plain text field by its form field name.
A part that uploads a file is skipped, so a file field never silently decodes as text.
§Arguments
&[BodyPart]- The decoded parts of the body.K- The form field name, which requires theAsRef<str>bound.
§Returns
Option<BodyFormValue>- The field value, orNonewhen absent or a file.
Sourcepub fn parse_url_encoded<B>(
body: B,
) -> HashMap<String, String, BuildHasherDefault<Hasher>>
pub fn parse_url_encoded<B>( body: B, ) -> HashMap<String, String, BuildHasherDefault<Hasher>>
Trait Implementations§
Source§impl Clone for MultipartFormData
impl Clone for MultipartFormData
Source§fn clone(&self) -> MultipartFormData
fn clone(&self) -> MultipartFormData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more