Allure Reqwest configuration
This page describes CaptureOptions, which controls what AllureReqwestMiddleware and AllureReqwestClient record. Build it with the builder methods below and pass it with .with_options(...):
use allure_reqwest::{AllureReqwestClient, CaptureOptions};
let client = AllureReqwestClient::new(allure).with_options(
CaptureOptions::default()
.with_attachment_name("Create order")
.with_response_body_capture(64 * 1024),
);Customize the attachment name
with_attachment_name(name: impl Into<String>)
Sets a fixed name for the step and attachment created for every captured exchange. By default, every exchange is attached under the name HTTP Exchange. Unlike some other Allure HTTP integrations, the name is always a static string — there is no callback that derives it from the request or response.
Control body capture
without_request_body_capture()— request bodies are captured by default; call this to disable itwith_response_body_capture(max_body_size: usize)— response bodies are not captured by default; call this to enable itwithout_response_body_capture()with_max_body_size(max_body_size: usize)— sets the byte limit
WARNING
There is only one size limit, shared by both request and response body capture — not independent limits per side. with_response_body_capture(n) and with_max_body_size(n) set the same underlying value, so whichever one you call last wins for both sides:
use allure_reqwest::CaptureOptions;
// max_body_size ends up 1024 for BOTH request and response capture — the with_max_body_size(5)
// call is overwritten by with_response_body_capture's own argument, which runs after it.
let a = CaptureOptions::default()
.with_max_body_size(5)
.with_response_body_capture(1024);
// max_body_size ends up 5 for BOTH sides — with_max_body_size runs last here.
let b = CaptureOptions::default()
.with_response_body_capture(1024)
.with_max_body_size(5);If you want a specific request-body limit together with response capture, call with_max_body_size(...) after with_response_body_capture(...).
The default limit is 64 KiB (65536 bytes). Bodies larger than the limit are captured up to the limit and flagged truncated: true in the attachment — size still reports the full, untruncated byte count. See the reference for the exact fields.
Response bodies are only captured when the body can be fully buffered: AllureReqwestClient and AllureReqwestMiddleware read the response into memory, record it, and reconstruct an equivalent Response so your test code can still read it normally afterward.
Redaction
Sensitive header and query-parameter values are replaced with the sentinel string __ALLURE_REDACTED__ before the attachment is written. The defaults are:
| Category | Redacted by default |
|---|---|
| Headers | authorization, cookie, proxy-authorization, set-cookie |
| Query parameters | access_token, api_key, key, password, refresh_token, secret, token |
Matching is by exact name, case-insensitive — there is no regex or pattern matching.
redact_header(name: impl Into<String>)redact_query_param(name: impl Into<String>)
Both add a name to the existing redaction list rather than replacing it — there is no way to remove a default redacted name, only to add more:
use allure_reqwest::CaptureOptions;
let options = CaptureOptions::default()
.redact_header("x-internal-secret")
.redact_query_param("session_id");
// authorization, cookie, etc. are still redacted, plus these two.Errors
When a request fails — a transport error, or a failure while reading the response body — the attachment's error field records the error's type name (reqwest::Error for AllureReqwestClient, reqwest_middleware::Error for AllureReqwestMiddleware) and its display message. There is no option to capture a stack trace.
HTTP error status codes (4xx/5xx) are not treated as errors by allure-reqwest — reqwest itself does not treat them as errors either, so the attachment gets a normal response with no error, the same as any other status code. Call .error_for_status() yourself if you want reqwest to turn a 4xx/5xx response into an Err.