fibre_http is an HTTP client for Rust that works the same way from async code and from blocking code. You make an AsyncClient or a SyncClient. to_sync() and to_async() turn one into the other for free. Both share one connection pool, so a thread and a task can use the same HTTP/2 connection.
A blocking call does its own I/O on its own thread, so there is no background runtime to start. You can begin a request in async code and read the body on a blocking thread.
It speaks HTTP/1.1 with keep-alive and HTTP/2 with multiplexing. TLS is rustls by default, with native-tls as an option. Proxies, redirects, retries, per-request deadlines and streamed request bodies are built in.
use AsyncClient;
let client = new;
let page = client.get.send.await?.text.await?;
let blocking = client.clone.to_sync;
let page = spawn_blocking.await.unwrap?;Requests a second for 64-byte GETs to a local hyper server with N concurrent callers, on an Apple M4 Pro. Higher is better. hyper is the low-level client most Rust HTTP clients are built on, so it is shown as a yardstick and not ranked.
| N | fibre_http async | fibre_http blocking | reqwest async | reqwest blocking | hyper (yardstick) | |
|---|---|---|---|---|---|---|
| HTTP/1.1 | 1 | 42,498 | 43,149 | 35,762 | 26,945 | 42,855 |
| HTTP/1.1 | 8 | 141,966 | 132,618 | 127,205 | 82,051 | 146,463 |
| HTTP/1.1 | 32 | 169,772 | 124,303 | 171,444 | 85,636 | 174,848 |
| h2c | 1 | 36,040 | 39,506 | 31,806 | 23,837 | 40,714 |
| h2c | 8 | 102,049 | 84,630 | 71,631 | 77,187 | 83,779 |
| h2c | 32 | 126,029 | 73,086 | 74,301 | 112,085 | 81,692 |
