Expand description
A browser-shaped HTTP client.
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.
use web_faith::Agent;
let agent = Agent::new()?;
let body = agent.fetch("https://example.com/").await?.text().await?;§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:
cargo add web-faith -F http3# .cargo/config.toml
[build]
rustflags = ["--cfg", "reqwest_unstable"]§Features
| Feature | Default | What it adds |
|---|---|---|
cache | ✓ | The HTTP cache. |
connection-tracking | ✓ | Kernel connection counters. |
cookies | ✓ | The cookie jar. |
dns | ✓ | Faith’s own caching resolver. Without it, names resolve through the platform. |
encoding | ✓ | Content codings for request and response bodies. |
tls-aws-lc-rs | ✓ | aws-lc-rs as the rustls crypto provider. |
tls-ring | ring as the rustls crypto provider instead. | |
http3 | Transparent HTTP/3, upgraded into via Alt-Svc. Needs the cfg flag above. | |
raw-client | Access to the reqwest client underneath. | |
unstable-internals | Faith’s internals. Permanently unstable and exempt from semver. |
§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.
Re-exports§
pub use agent::Agent;pub use error::FaithError;pub use request::Request;pub use response::Response;
Modules§
- agent
- The agent and its builder.
- error
- Errors.
- request
- Requests and their builders.
- response
- Responses, bodies, and request timing.
Constants§
- USER_
AGENT - The
User-Agenta request carries when nothing overrides it.