Skip to main content

fetch_request

Function fetch_request 

Source
pub async fn fetch_request(
    endpoint: &IrohEndpoint,
    addr: &EndpointAddr,
    req: Request<Body>,
    cfg: &StackConfig,
) -> Result<Response<Body>, FetchError>
Expand description

Pure-Rust outbound entry — the canonical client API.

Establishes (or reuses, via [crate::http::transport::pool]) an Iroh QUIC connection to addr, runs hyper’s HTTP/1.1 client handshake on a freshly opened bidirectional stream, dispatches req through the shared client tower stack ([crate::http::server::stack::build_client_stack]), and returns the response.

The returned hyper::Response<Body> streams its body lazily; the caller is responsible for draining it.

§Errors

Returns FetchError::Timeout if cfg.timeout is set and elapsed before the response head arrived. Connection / handshake / transport failures map to FetchError::ConnectionFailed.