expression
Reqwest: clone a replayable request builder
A buffered request can usually be cloned before sending; a one-shot body stream might not be cloneable. Cloneability describes a technical ability, not permission to repeat a side effect. Retry only when the operation contract and failure evidence permit. In-memory fixture; no external connection. Expected stdout (not executed): true true Common mistake: Retrying every POST merely because its builder is cloneable.
Formal Syntax & Structure
rust syntaxrust
builder.try_clone() -> Option<RequestBuilder>Working Example
Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() { let c = reqwest::Client::builder().no_proxy().build().unwrap(); let b = c.post("https://example.com/items").body("draft"); let copy = b.try_clone().unwrap().build().unwrap(); let original = b.build().unwrap(); println!("{}", original.method() == copy.method()); println!("{}", original.body().unwrap().as_bytes() == copy.body().unwrap().as_bytes());}