#hyper #multipart #form #http

hyper-multipart-rfc7578

An implementation of multipart/form-data (RFC7578) for Hyper

7 releases

0.3.0 Feb 9, 2019
0.2.0-alpha2 Jun 27, 2018
0.1.0 Feb 9, 2019
0.1.0-alpha3 Mar 23, 2018
0.1.0-alpha2 Dec 1, 2017

#2 in #form

Download history 63/week @ 2018-12-20 49/week @ 2018-12-27 66/week @ 2019-01-03 99/week @ 2019-01-10 115/week @ 2019-01-17 65/week @ 2019-01-24 72/week @ 2019-01-31 146/week @ 2019-02-07 96/week @ 2019-02-14 123/week @ 2019-02-21 178/week @ 2019-02-28 58/week @ 2019-03-07 63/week @ 2019-03-14 157/week @ 2019-03-21 108/week @ 2019-03-28

440 downloads per month
Used in 10 crates (3 directly)

MIT/Apache

28KB
401 lines


lib.rs:

This crate contains an implementation of the multipart/form-data media type described in RFC 7578 for hyper.

Usage

Declare the dependency:

[dependencies]
hyper-multipart-rfc7578 = "0.1.0"

Import the crate:

extern crate hyper_multipart_rfc7578 as multipart;

Example:

With a custom client:

# extern crate hyper;
# extern crate hyper_multipart_rfc7578 as hyper_multipart;

use hyper::{
    rt::{self, Future},
    Client, Request,
};
use hyper_multipart::client::{self, multipart};

# fn main() {
let client = Client::builder().build_http();
let mut form = multipart::Form::default();

form.add_text("test", "Hello World");

let mut req_builder = Request::get("http://localhost/upload");

let req = form.set_body::<multipart::Body>(&mut req_builder).unwrap();

rt::run(
    client
        .request(req)
        .map(|_| println!("done..."))
        .map_err(|_| println!("an error occurred")),
);
# }

With a default client:

# extern crate hyper;
# extern crate hyper_multipart_rfc7578 as hyper_multipart;

use hyper::{
    rt::{self, Future},
    Client, Request,
};
use hyper_multipart::client::{self, multipart};

# fn main() {
let client = Client::new();
let mut form = multipart::Form::default();

form.add_text("test", "Hello World");

let mut req_builder = Request::get("http://localhost/upload");

let req = form.set_body_convert::<hyper::Body, multipart::Body>(&mut req_builder)
    .unwrap();

rt::run(
    client
        .request(req)
        .map(|_| println!("done..."))
        .map_err(|_| println!("an error occurred")),
);
# }

Dependencies

~4MB
~71K SLoC