#mio #http #non-blocking #http-request #client #simple

rtv

Minimal HTTP/S client that supports nonblocking and streaming requests using mio

11 releases (4 major breaking)

4.0.1 Jan 18, 2024
3.0.0 Oct 31, 2023
2.0.1 Jun 20, 2023
1.2.0 May 30, 2023
0.1.2 Sep 7, 2021

#124 in HTTP client

MIT license

80KB
1.5K SLoC

Rtv

Rtv is a simple, minimal dependency, HTTP client that runs ontop of mio. It supports fully nonblocking requests, even dns resolution is nonblocking. You can also use it with async as a much more light weight (but also less robust and featurefull) alternative to something like hyper.

You can either setup mio youself and then use a Client to make requests using your own Poll or alternatively you can use a SimpleClient if you want to use async. However the latter is currently supported on 64 bit unix only.

Example (Client)

This is the main functionality that this crate provides. You can find an example here on docs.rs.

Example (SimpleClient)

It is really simple to make a single request. This is not the only functionality that this client provides though!

let mut client = SimpleClient::new()?;
let request = Request::get().host("google.com");
client.send(request).await?;

Mio Httpc

This crate is similar to mio_httpc, however the API is much more clean, in my opinion. MioHttpc makes event handling, timeouts and errors very verbose, while this crate aims to provide a much simpler interface that only requires calling one function (pump). Rtv supports only a subset of mio_httpc's features though and is probably not as efficient and stable. Rtv really is a simple HTTP client.

Notes

Earlier versions of this crate were completely different. I decided to repurpose the name because I don't wanna litter my profile or crates.io.

  • First rtv was a crate for doing recursive-file-traversal
  • Then it was a crate for resolving futures (completely useless)

Dependencies

~0.7–13MB
~133K SLoC