mio_httpc is an async http client that runs on top of mio only.
For convenience it also provides CallBuilder::exec for a simple one-line blocking HTTP call.
Except CallBuilder::exec no call will block, not even for DNS resolution as it is implemented internally to avoid blocking.
For https to work mio_httpc requires you specify one of the TLS implementations using features: native, openssl or rtls (rustls). Default build will fail on any https URI.
CallBuilder also has URL construction functions (host/path_segm/query/set_https/auth/https) which will take care of url-safe encoding.
mio_httpc does a minimal amount of allocation and in general works with buffers you provide and an internal pool of buffers that get reused on new calls.
TODO/FEATURE LIST
- Basic API
- Configurable TLS backend
- Chunked encoding download
- Chunked encoding upload
- Safe URL construction
- Basic Auth
- Digest Auth
- Automatic redirects
- Keep-alive connection pool
- DNS retries
- Timeouts
- Websockets
- gzip body decoding
- HTTP2
EXAMPLES
Sync call
extern crate mio_httpc;
use CallBuilder;
// One line blocking call.
let = get.timeout_ms.url?.exec?;
// With URL construction.
// This way of building the URL is highly recommended as it will always result in correct
// values by percent encoding any URL unsafe characters.
// This calls: https://www.example.com/a/b?key1=val1
let = get
.timeout_ms
.https
.host
.path_segm
.path_segm
.query
.exec?;
Basic async get
cargo run --example get --features "native" -- "https://edition.cnn.com"
// or
cargo run --example get --features "openssl" -- "https://edition.cnn.com"
// or
cargo run --example get --features "rtls" -- "https://edition.cnn.com"
extern crate mio_httpc;
extern crate mio;
use ;
use ;
Websockets
cargo run --example ws --features="native" -- "wss://demos.kaazing.com/echo"
extern crate mio_httpc;
extern crate mio;
use ;
use ;
// ws://demos.kaazing.com/echo