#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

#99 in Web programming

Download history 83/week @ 2018-10-27 76/week @ 2018-11-03 101/week @ 2018-11-10 60/week @ 2018-11-17 33/week @ 2018-11-24 77/week @ 2018-12-01 129/week @ 2018-12-08 57/week @ 2018-12-15 47/week @ 2018-12-22 64/week @ 2018-12-29 67/week @ 2019-01-05 118/week @ 2019-01-12 103/week @ 2019-01-19 63/week @ 2019-01-26 75/week @ 2019-02-02

325 downloads per month
Used in 11 crates (4 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
~70K SLoC