1 unstable release

0.1.0 Jun 27, 2021

#618 in HTTP server

Download history 1479/week @ 2023-12-11 1029/week @ 2023-12-18 410/week @ 2023-12-25 645/week @ 2024-01-01 1141/week @ 2024-01-08 1154/week @ 2024-01-15 1401/week @ 2024-01-22 1083/week @ 2024-01-29 758/week @ 2024-02-05 1379/week @ 2024-02-12 1337/week @ 2024-02-19 1258/week @ 2024-02-26 1380/week @ 2024-03-04 1457/week @ 2024-03-11 1144/week @ 2024-03-18 875/week @ 2024-03-25

4,889 downloads per month
Used in warp-fix-171

MIT/Apache

42KB
884 lines

multiparty

crates.io Documentation dependency status Rustc Version 1.45.2+ CI codecov

Simple zero copy* streaming multipart decoder implementation.

Also exposes the underlying Sans IO decoder, for use outside of the futures 0.3 ecosystem.

Examples

multiparty = { version = "0.1", features = ["server", "futures03"] }
use multiparty::server::owned_futures03::FormData;
use futures_util::stream::TryStreamExt;

let boundary = todo!("A multipart/form-data boundary");
let stream = todo!("A Stream<Item = std::io::Result<Bytes>> + Unpin");
let mut multipart = FormData::new(stream, boundary);

while let Some(mut part) = multipart.try_next().await? {
    let headers = part.raw_headers().parse()?;
    println!("name: {:?}", headers.name);
    println!("filename: {:?}", headers.filename);
    println!("content_type: {:?}", headers.content_type);

    while let Some(bytes) = part.try_next().await? {
        println!("Read {} bytes from the current part", bytes.len());
    }

    println!("Reached the end of this part");
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.


* Except for streams yielding Bytes smaller than half the boundary length.

Dependencies

~130–290KB