#http #upload #http-post #client-server #form-data #hyper #iron

bin+lib multipart-2021

A backend-agnostic extension for HTTP libraries that provides support for POST multipart/form-data requests on both client and server

1 unstable release

0.19.0 Apr 23, 2023

#587 in HTTP server

Download history 108/week @ 2024-07-23 84/week @ 2024-07-30 110/week @ 2024-08-06 70/week @ 2024-08-13 136/week @ 2024-08-20 120/week @ 2024-08-27 56/week @ 2024-09-03 77/week @ 2024-09-10 25/week @ 2024-09-17 47/week @ 2024-09-24 24/week @ 2024-10-01 85/week @ 2024-10-08 24/week @ 2024-10-15 36/week @ 2024-10-22 43/week @ 2024-10-29 125/week @ 2024-11-05

232 downloads per month

MIT/Apache

175KB
3.5K SLoC

Multipart 2021 On Crates.io

Client- and server-side abstractions for HTTP file uploads (POST requests with Content-Type: multipart/form-data).

Supports several different (synchronous API) HTTP crates. Asynchronous (i.e. futures-based) API support will be provided by multipart-async.

About the fork

multipart-2021 is a fork of the original which has now been archived.

The fork only updates the library to support Rust 2018 and 2021 edition changes, no changes or improvements to the API are intended.

You can rebind your import of multipart-2021 so that all the examples continue to work as normal:

use multipart_2021 as multipart;
Minimum supported Rust version: 1.56.0
Maintenance Status: Archived

As the web ecosystem in Rust moves towards asynchronous APIs, the need for this crate in synchronous API form becomes dubious. This crate in its current form is usable enough, so as of June 2020 it is now in passive maintenance mode; bug reports will be addressed as time permits and PRs will be accepted but otherwise no new development of the existing API is taking place.

Look for a release of multipart-async soon which targets newer releases of Hyper.

Documentation

Integrations

Example files demonstrating how to use multipart with these crates are available under examples/.

Hyper

via the hyper feature (enabled by default).

Note: Hyper 0.9, 0.10 (synchronous API) only; support for asynchronous APIs will be provided by multipart-async.

Client integration includes support for regular hyper::client::Request objects via multipart::client::Multipart, as well as integration with the new hyper::Client API via multipart::client::lazy::Multipart (new in 0.5).

Server integration for hyper::server::Request via multipart::server::Multipart.

Iron

via the iron feature.

Provides regular server-side integration with iron::Request via multipart::server::Multipart, as well as a convenient BeforeMiddleware implementation in multipart::server::iron::Intercept.

Nickel returning to multipart in 0.14!

via the nickel feature.

Provides server-side integration with &mut nickel::Request via multipart::server::Multipart.

tiny_http

via the tiny_http feature.

Provides server-side integration with tiny_http::Request via multipart::server::Multipart.

Rocket

Direct integration is not provided as the Rocket folks seem to want to handle multipart/form-data behind the scenes which would supercede any integration with multipart. However, an example is available showing how to use multipart on a Rocket server: examples/rocket.rs

⚡ Powered By ⚡

buf_redux

Customizable drop-in std::io::BufReader replacement, created to be used in this crate. Needed because it can read more bytes into the buffer without the buffer being empty, necessary when a boundary falls across two reads. (It was easier to author a new crate than try to get this added to std::io::BufReader.)

httparse

Fast, zero-copy HTTP header parsing, used to read field headers in multipart/form-data request bodies.

twoway

Fast string and byte-string search. Used to find boundaries in the request body. Uses SIMD acceleration when possible.

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, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~10–21MB
~335K SLoC