expression

Reqwest: separate client and request

Split construction into the original client and a request result. The request can be inspected before executing with that client. This example stops before execution, keeping the network boundary visible. In-memory fixture; no external connection. Expected stdout (not executed): GET /stock Common mistake: Treating build_split as a send or response operation.

Formal Syntax & Structure

rust syntaxrust
let (client, result) = builder.build_split();

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() {    let c = reqwest::Client::builder().no_proxy().build().unwrap();    let (client, result) = c.get("https://example.com/stock").build_split();    let request = result.unwrap();    println!("{} {}", request.method(), request.url().path());    let _next = client.get("https://example.com/next");}
Rust Reference