Module hyper_multipart_rfc7578_mem_uploads::client [] [src]

Multipart RFC 7578 - Client

This module contains code related to making requests with a multipart/form body.

All data structures related to constructing a multipart/form body are in the submodule multipart.

This module contains a helper method to build a hyper client that can send a multipart body. See.

Examples

The most basic scenario would be creating a client with the provided function.

use hyper::{Method, Request};
use hyper::client::Client;
use hyper_multipart_rfc7578::client::{self, multipart};
use tokio_core::reactor::{Core, Handle};

let mut core = Core::new().unwrap();
let client: Client<_, multipart::Body> = client::create(&core.handle());
let mut req = Request::new(Method::Get, "http://localhost/upload".parse().unwrap());
let mut form = multipart::Form::default();

form.add_text("test", "Hello World");
form.set_body(&mut req);

core.run(client.request(req));

You can also manually create a hyper client with a different connector, or different configuration using hyper's Config object.

use hyper::{Method, Request};
use hyper::client::{Client, Config};
use hyper_multipart_rfc7578::client::multipart;
use hyper_tls::HttpsConnector;
use tokio_core::reactor::{Core, Handle};

let mut core = Core::new().unwrap();
let client: Client<HttpsConnector<_>, multipart::Body> =
    Config::default()
        .body::<multipart::Body>()
        .connector(HttpsConnector::new(2, &core.handle()).unwrap())
        .keep_alive(true)
        .build(&core.handle());
let mut req = Request::new(Method::Get, "http://localhost/upload".parse().unwrap());
let mut form = multipart::Form::default();

form.add_text("test", "Hello World");
form.set_body(&mut req);

core.run(client.request(req));

Modules

multipart

This module contains data structures for building a multipart/form body to send a server.

Functions

create

Creates a hyper client with a multipart body.