HTTP client library that integrates with mio?


#1

I have a mio-based event loop that manages several TCP connections (some of
which runs TLS + websockets) and now I want to add some HTTP connections to the
loop.

The libraries I could find were either unmaintained (e.g. rotor-http), or
required tokio (e.g. hyper) or just allowed blocking requests (e.g. reqwest).

I’m wondering if there are HTTP client libraries that gives me a as_raw_fd()
and progress() (something that reads from the socket/ writes to it depending
on the readiness and whether it’s sending or receiving) functions.

I don’t want to switch to tokio because I don’t like the API (ridiculously
complex, comes with its own book as user manual, I don’t like callback/FnOnce
-heavy code…), examples are too trivial to be useful (which would be OK if the
API was comprehensible).

Any ideas?


#2

Hmm, I’ve not heard of one like that. Perhaps you can use an http parsing lib but continue using mio yourself for the socket handling? https://github.com/seanmonstar/httparse would be one example of an http parser.

Have you looked at hyper? It’s tokio based internally but exposes its own API. However, it’ll be closure based.

As for a good Tokio example app, the best I’ve seen is the socks5 proxy implementation: https://github.com/tokio-rs/tokio-socks5/blob/master/src/main.rs


#3

Hey, @osa1. I’m facing a similar problem as you. Which HTTP connection impl did you settle with for your custom loop?


#4

Hey @discosultan,

I decided to wait until futures matures and reqwest merges the non-blocking client (it’s currently behind a feature flag).