HTTP backends and TLS
Backend selection
Section titled “Backend selection”The default stack is reqwest + Rustls:
jingzhe = "0.1.0"To use ureq with Native TLS:
jingzhe = { version = "0.1.0", default-features = false, features = ["ureq", "native-tls"] }| Feature | Purpose | Default |
|---|---|---|
reqwest |
Tokio-native async HTTP client | Yes |
ureq |
HTTP client executed on Tokio blocking tasks | No |
rustls-tls |
Enable Rustls for the selected backend | Yes |
native-tls |
Enable Native TLS for the selected backend | No |
When exactly one HTTP backend is enabled, Bot::new(token) selects it automatically. Construction fails when no backend or both backends are enabled.
Select a backend explicitly:
use jingzhe::{Bot, HttpBackend};
let bot = Bot::with_backend(token, HttpBackend::Reqwest)?;Selecting a backend that was not compiled returns an error. With both backends compiled and an explicit choice, tracing suggests disabling the unused feature. Query the active backend with bot.client().backend().
TLS behavior
Section titled “TLS behavior”- TLS features do not implicitly enable an HTTP backend.
- Rustls wins when both TLS implementations are enabled.
- Without TLS, local HTTP endpoints are allowed, but HTTPS requests return a configuration error.
Transport behavior
Section titled “Transport behavior”Constructing a client does not access the network. The total request timeout covers connection, sending, and response reading. The connection timeout is capped at 10 seconds.
Both backends disable redirects and automatic retries, and preserve unsuccessful HTTP responses for the caller to interpret. Response::chunk() returns chunks; the caller is responsible for enforcing a total size limit.
ureq transfers data through a channel with capacity one to prevent an unbounded background buffer. Dropping the response stops background reading when the channel closes or the current network operation ends. A blocking operation that already started cannot be interrupted immediately, but it remains subject to the request timeout.
Proxies
Section titled “Proxies”When using the library directly, the selected backend detects standard environment proxies and NO_PROXY according to the target protocol.
Recommended for HTTPS targets:
export HTTPS_PROXY=http://127.0.0.1:7890Proxy settings can also be configured explicitly:
let bot = bot.proxy_url("http://127.0.0.1:7890")?;let bot = bot.proxy_url_with_bypass(proxy, bypass)?;let bot = bot.no_proxy();Explicit proxies currently support HTTP/HTTPS only; SOCKS is not enabled. NO_PROXY matching rules are interpreted by the selected backend.
See the complete transport reference in crates/http/README.md.