Skip to content

trillium-client-v0.7.0

Choose a tag to compare

@jbr jbr released this 02 May 22:37
· 191 commits to main since this release
ca48261

Changed

  • Compatible with trillium 1.0
  • ObjectSafeConnector replaced by ArcedConnector; config.arced()ArcedConnector::new(config)
  • Error variants renamed: MalformedHeader split into InvalidHeaderName and InvalidHeaderValue; PartialHead merged into InvalidHead
  • Maximum head size increased from 2KB to 8KB
  • Previously deprecated with_header, with_headers, and without_header removed
  • async_trait re-export removed
  • Client::with_default_pool removed and keepalive is now the default. To opt out, Client::without_keepalive was added
  • Conn::response_body now returns a trillium_client::ResponseBody instead of a trillium_http::ReceivedBody

Added

HTTP/3

Client::new_with_quic(connector, quic_connector) builds a client with HTTP/3 support. The client tracks Alt-Svc response headers and automatically uses HTTP/3 for subsequent requests to origins that advertise it. QUIC connections are pooled; if an H3 attempt fails, that endpoint is marked broken and requests fall back to HTTP/1.1 for a backoff period before retrying. Requests to origins without a cached alt-svc entry always use HTTP/1.1.

QuicClientConfig and ArcedQuicClientConfig are re-exported from trillium-server-common. The QuicClientConfig type parameter is bound at construction time (before type erasure), keeping trillium-quinn and the runtime adapter as independent crates that neither depends on the other.

use trillium_client::Client;
use trillium_rustls::RustlsConfig;
use trillium_rustls::rustls::client::ClientConfig;
use trillium_quinn::ClientQuicConfig;

let client = Client::new_with_quic(
    RustlsConfig::<ClientConfig>::default(),
    ClientQuicConfig::with_webpki_roots(),
);

Other additions

  • Conn::http_version() -> Version — returns the HTTP version used for the request; after the request completes this reflects whether HTTP/3 was negotiated
  • Client::with_timeout(Duration) and Conn::with_timeout(Duration) — per-request timeouts, returning Error::TimedOut on expiry
  • Client::set_timeout(&mut self, Duration) and Conn::set_timeout(&mut self, Duration) — in-place variants of the above
  • Per-connection state via TypeSet: with_state, insert_state, state, state_mut, take_state
  • sonic-rs feature: opt-in alternative to serde_json for with_json_body and response_json. Enable with features = ["sonic-rs"]. The two features are mutually exclusive — enable only one. Note: unlike serde_json, sonic-rs does not guarantee stable map key ordering — tests that assert on raw JSON string output may need to parse back to Value before comparing. To keep using serde_json, use features = ["serde_json"].

Added

  • deprecate Headers::contains_ignore_ascii_case
  • (client) impl IntoUrl for IpAddr and SocketAddr for convenience