pub fn parse_multipart_with<'a>(
content_type: &[u8],
body: &'a [u8],
limits: &Limits,
policy: &Policy,
) -> Result<Multipart<'a>, FormError>Available on crate feature
alloc only.Expand description
As parse_multipart with explicit limits and policy.
limits.validate() runs first. The token rule of Policy::token_field
applies; the captured token is the value of the text field with that
name.
§Errors
As parse_multipart; InvalidLimits.
§Examples
use form_net::{Limits, Policy};
const AVATAR: Limits = Limits::DEFAULT
.with_max_body_bytes(512 * 1024)
.with_max_parts(4)
.with_max_files(1);
let body = b"--X\r\nContent-Disposition: form-data; name=f; filename=a\r\n\r\n1\r\n--X--";
let mp = form_net::parse_multipart_with(b"multipart/form-data; boundary=X", body, &AVATAR, &Policy::DEFAULT)?;
assert_eq!(mp.len(), 1);