web-faith 1.0.0

A browser-shaped HTTP client: fetch semantics over a Rust network stack
Documentation
web-faith-1.0.0 has been yanked.

web-faith

A browser-shaped HTTP client.

crates.io docs.rs

Faith behaves like a browser ("faithfully") wherever that translates to a server-side runtime: transparent HTTP/2 and HTTP/3 upgrades, Happy Eyeballs across IPv4 and IPv6, DNS caching, an optional cookie jar, and HTTP caching. We also publish the reusable components as separate crates.

Usage

[dependencies]
web-faith = "1.0"
use web_faith::{FaithError, agent::Agent};

#[tokio::main]
async fn main() -> Result<(), FaithError> {
	let agent = Agent::new()?;
	let body = agent.fetch("https://example.com/").await?.text().await?;
	println!("{body}");
	Ok(())
}

HTTP/3 is opt-in

Faith uses reqwest internally, and its HTTP/3 support is currently unstable. To enable HTTP/3 support, you will need to set the http3 feature on Faith, and use the reqwest_unstable rustc cfg flag:

[dependencies]
web-faith = { version = "1.0", features = ["http3"] }
# .cargo/config.toml
[build]
rustflags = ["--cfg", "reqwest_unstable"]

Features

Feature Default What it adds
cache on The HTTP cache, its store, and the per-request cache mode.
connection-tracking on Per-connection kernel counters, and the agent verb that reports them.
cookies on The cookie jar, and the agent option and handle that reach it.
dns on Faith's own caching resolver. Without it, names resolve through the platform.
encoding on Content codings: negotiating and decoding a response body, and compressing a request one.
tls-aws-lc-rs on The rustls crypto provider. tls-ring selects ring instead.
http3 off Transparent HTTP/3, and the Alt-Svc machinery that upgrades an origin to it. Needs the cfg flag above.

Component crates

Elsewhere

Faith is also a Node.js module which lets you use this Rust networking stack as a fetch drop-in replacement: @passcod/faith.

Licence

Apache-2.0 or MIT.