kithara-net 0.0.1-alpha1

HTTP networking with retry, timeout, and streaming support
Documentation

License

kithara-net

HTTP networking with retry, timeout, and streaming support. Provides the Net trait for HTTP operations and HttpClient as the default reqwest-based implementation. Includes TimeoutNet decorator and MockNet for testing.

Usage

use kithara_net::{HttpClient, Net, NetOptions};

let client = HttpClient::new(NetOptions::default());
let bytes = client.get_bytes(url, &NetOptions::default()).await?;
let stream = client.stream(url, &NetOptions::default()).await?;

Decorators

TimeoutNet<N> wraps all methods with tokio::time::timeout and is exported in the public API. A retry decorator with exponential backoff (retries on 5xx, 429, 408, timeouts; does not retry on other 4xx) is also available, but only via the NetExt builder methods — the wrapper type itself is not part of the public surface.

Decorators compose via the NetExt extension trait:

use kithara_net::{HttpClient, Net, NetExt, NetOptions, RetryPolicy};
use std::time::Duration;
use tokio_util::sync::CancellationToken;

let client = HttpClient::new(NetOptions::default())
    .with_retry(RetryPolicy::default(), CancellationToken::new())
    .with_timeout(Duration::from_secs(30));

Key Types

Timeout Behavior

  • get_bytes() and head(): apply request_timeout from options.
  • stream(): no timeout (designed for long-running downloads).
  • The TimeoutNet decorator can override with a custom timeout.

Integration

Used by kithara-file and kithara-hls for all HTTP operations. MockNet (behind the mock feature) enables deterministic testing without network access.