#![deny(missing_docs)]
#![cfg_attr(target_arch = "wasm32", allow(dead_code))]
#[cfg(not(any(
feature = "tokio",
feature = "smol",
feature = "compio",
feature = "wasm",
feature = "wasi-p2",
doc
)))]
compile_error!(
"aioduct: enable at least one runtime feature: tokio, smol, compio, wasm, or wasi-p2"
);
#[cfg(all(feature = "http3", not(feature = "rustls")))]
compile_error!("aioduct: the `http3` feature currently requires the `rustls` TLS backend feature");
pub mod bandwidth;
pub mod body;
pub mod cache;
pub mod cookie;
mod decompress;
mod digest_auth;
pub mod error;
pub mod forwarded;
pub(crate) mod h2c_probe;
pub mod hsts;
pub mod http2;
pub mod link;
pub mod middleware;
pub mod multipart;
pub mod netrc;
pub mod proxy;
pub mod redirect;
pub mod retry;
pub mod sse;
pub mod throttle;
pub mod timing;
#[cfg(feature = "json")]
pub mod problem;
#[cfg(feature = "blocking")]
pub mod blocking;
#[cfg(not(target_arch = "wasm32"))]
pub mod chunk_download;
#[cfg(not(target_arch = "wasm32"))]
pub mod client;
#[cfg(feature = "tower")]
pub mod connector;
#[cfg(not(target_arch = "wasm32"))]
pub mod forward;
#[cfg(not(target_arch = "wasm32"))]
mod happy_eyeballs;
#[cfg(feature = "hickory-dns")]
pub mod hickory;
#[cfg(not(target_arch = "wasm32"))]
pub(crate) mod pool;
#[cfg(not(target_arch = "wasm32"))]
pub mod request;
#[cfg(not(target_arch = "wasm32"))]
pub mod response;
#[cfg(not(target_arch = "wasm32"))]
pub mod runtime;
#[cfg(not(target_arch = "wasm32"))]
mod socks4;
#[cfg(not(target_arch = "wasm32"))]
mod socks5;
#[cfg(not(target_arch = "wasm32"))]
mod timeout;
#[cfg(not(target_arch = "wasm32"))]
pub mod tls;
#[cfg(not(target_arch = "wasm32"))]
pub mod upgrade;
#[cfg(feature = "wasm")]
pub mod wasm;
#[cfg(feature = "wasi-p2")]
pub mod wasi_p2;
#[cfg(feature = "tracing")]
mod tracing_middleware;
#[cfg(feature = "tracing")]
pub use tracing_middleware::TracingMiddleware;
#[cfg(feature = "otel")]
mod otel_middleware;
#[cfg(feature = "otel")]
pub use otel_middleware::OtelMiddleware;
#[cfg(all(feature = "http3", feature = "rustls"))]
mod alt_svc;
#[cfg(all(feature = "http3", feature = "rustls"))]
#[path = "h3/mod.rs"]
pub mod h3_transport;
pub use bandwidth::BandwidthLimiter;
pub use body::{BodyStream, RequestBody};
pub use cache::{CacheConfig, CacheEntry, CacheStore, HttpCache, InMemoryCacheStore};
pub use cookie::{Cookie, CookieJar, SameSite};
pub use error::{AioductBody, Error};
pub use forwarded::ForwardedElement;
pub use hsts::HstsStore;
pub use http2::Http2Config;
pub use link::Link;
pub use middleware::Middleware;
pub use multipart::{Multipart, Part};
pub use netrc::{Netrc, NetrcMiddleware};
pub use proxy::{NoProxy, ProxyConfig, ProxySettings};
pub use redirect::{RedirectAction, RedirectPolicy};
pub use retry::{RetryBudget, RetryConfig};
pub use sse::{SseDecoder, SseEvent, SseMessage, SseStream};
pub use throttle::RateLimiter;
pub use timing::RequestTimings;
#[cfg(feature = "json")]
pub use problem::ProblemDetails;
#[cfg(not(target_arch = "wasm32"))]
pub use chunk_download::ChunkDownload;
#[cfg(not(target_arch = "wasm32"))]
pub use client::Client;
#[cfg(not(target_arch = "wasm32"))]
pub use forward::ForwardBuilder;
#[cfg(feature = "hickory-dns")]
pub use hickory::HickoryResolver;
#[cfg(not(target_arch = "wasm32"))]
pub use request::RequestBuilder;
#[cfg(not(target_arch = "wasm32"))]
pub use response::Response;
#[cfg(not(target_arch = "wasm32"))]
pub use runtime::{Resolve, Runtime};
#[cfg(not(target_arch = "wasm32"))]
pub use upgrade::Upgraded;
#[cfg(not(target_arch = "wasm32"))]
pub use tls::TlsInfo;
#[cfg(not(target_arch = "wasm32"))]
pub use tls::TlsVersion;
#[cfg(feature = "rustls")]
pub use tls::{Certificate, Identity};
pub use http::{HeaderMap, Method, StatusCode, Uri, Version};
#[cfg(not(target_arch = "wasm32"))]
pub use hyper::ext::Protocol;
#[cfg(feature = "__bench")]
#[doc(hidden)]
pub mod __bench {
use std::net::{IpAddr, SocketAddr};
use std::time::Duration;
use crate::pool::{ConnectionPool, PoolKey, PooledConnection};
use crate::runtime::TokioRuntime;
use http::uri::{Authority, Scheme};
pub struct BenchPool(ConnectionPool<TokioRuntime>);
pub struct BenchConn(Option<PooledConnection<TokioRuntime>>);
pub struct BenchKey(PoolKey);
pub fn new_pool(max_idle: usize, timeout: Duration) -> BenchPool {
BenchPool(ConnectionPool::new_no_reaper(max_idle, timeout))
}
pub async fn make_h2_conn() -> BenchConn {
use crate::runtime::tokio_rt::TokioIo;
let (client_io, server_io) = tokio::io::duplex(65536);
tokio::spawn(async move {
use hyper::server::conn::http2::Builder;
use hyper::service::service_fn;
let io = TokioIo::new(server_io);
let _ = Builder::new(crate::runtime::hyper_executor::<TokioRuntime>())
.serve_connection(
io,
service_fn(|_req| async {
Ok::<_, std::convert::Infallible>(hyper::Response::new(
http_body_util::Empty::<bytes::Bytes>::new(),
))
}),
)
.await;
});
let io = TokioIo::new(client_io);
let (sender, conn) = hyper::client::conn::http2::handshake(
crate::runtime::hyper_executor::<TokioRuntime>(),
io,
)
.await
.expect("h2 handshake");
tokio::spawn(async move {
let _ = conn.await;
});
BenchConn(Some(PooledConnection::new_h2(sender)))
}
pub fn pool_key(host: &str) -> BenchKey {
BenchKey(PoolKey::new(
Scheme::HTTPS,
host.parse::<Authority>().unwrap(),
))
}
pub fn set_sans(conn: &mut BenchConn, sans: Vec<String>) {
if let Some(c) = conn.0.as_mut() {
c.sans = sans;
}
}
pub fn set_remote_addr(conn: &mut BenchConn, addr: SocketAddr) {
if let Some(c) = conn.0.as_mut() {
c.remote_addr = Some(addr);
}
}
pub fn checkin(pool: &BenchPool, key: BenchKey, conn: BenchConn) {
if let Some(c) = conn.0 {
pool.0.checkin(key.0, c);
}
}
pub fn checkout_coalesced(
pool: &BenchPool,
target_host: &str,
resolved_ip: Option<IpAddr>,
) -> bool {
pool.0
.checkout_coalesced(target_host, resolved_ip)
.is_some()
}
}