pub struct FetchBuilder { /* private fields */ }Expand description
Builder for Client::fetch(...).send().await.
Implementations§
Source§impl FetchBuilder
impl FetchBuilder
pub fn render(self, mode: RenderMode) -> Self
pub fn wait(self, w: Wait) -> Self
pub fn timeout(self, d: Duration) -> Self
pub fn readiness_idle_ms(self, ms: u64) -> Self
pub fn readiness_stable_ms(self, ms: u64) -> Self
pub fn readiness_min_text_bytes(self, bytes: u64) -> Self
pub fn want<I: IntoIterator<Item = Artifact>>(self, items: I) -> Self
pub fn tab(self, tab: TabId) -> Self
Sourcepub fn keep_tab_open(self, keep: bool) -> Self
pub fn keep_tab_open(self, keep: bool) -> Self
Keep a freshly-opened target open after the fetch (for human takeover).
pub fn network_bodies(self, mode: NetworkBodies) -> Self
pub fn network_body_max_bytes(self, n: u64) -> Self
pub fn network_redact(self, on: bool) -> Self
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Add a request header. User-Agent is normalized to
Self::user_agent at send time so browser fetches use the CDP UA
override instead of a plain extra header.
Sourcepub fn user_agent(self, value: impl Into<String>) -> Self
pub fn user_agent(self, value: impl Into<String>) -> Self
Override the browser/client user agent.
Add a request cookie as a name=value pair.
Add a full cookie, including optional Domain/Path/Secure/HttpOnly/ SameSite/Max-Age/Expires attributes.
Add multiple request cookies as name=value pairs.
Sourcepub fn evaluate_after_wait(self, js: impl Into<String>) -> Self
pub fn evaluate_after_wait(self, js: impl Into<String>) -> Self
Evaluate JavaScript after the configured wait condition and before artifact capture. Only browser-backed fetches can execute scripts.
pub fn out_dir(self, dir: impl Into<PathBuf>) -> Self
Override the cookie-jar path. The default — derived from the host’s
GET /profile — places the jar at <profile-dir>/cookies.jar.json,
which is the only path the isolation invariant permits. This
override exists for tests and forensic tooling; the pipeline
canonicalizes the given path and rejects it with invalid_argument
if it doesn’t match the host’s profile directory.
Opt out of cookie-jar persistence for this fetch. The request goes
out without any session cookies the jar might hold, and the
response’s Set-Cookie headers are not merged back.
Sourcepub fn observe_main_wait_ms(self, ms: u64) -> Self
pub fn observe_main_wait_ms(self, ms: u64) -> Self
Upper bound on the browser-path wait for the main document network event, in milliseconds. Default 500ms is tuned for well-behaved pages on fast networks; raise for slow networks or low-end machines.
Sourcepub fn max_response_bytes(self, bytes: u64) -> Self
pub fn max_response_bytes(self, bytes: u64) -> Self
Upper bound on the HTTP-path response body, in bytes. Default
1 GiB. 0 disables the cap entirely. When the cap is hit, the
fetch returns successfully with a network_body_truncated
warning and the prefix bytes that were collected.
Sourcepub fn retry(self, n: u32) -> Self
pub fn retry(self, n: u32) -> Self
Number of additional attempts after the first. 0 (default)
keeps the single-attempt behavior. Retries only fire when the
pipeline error has retryable: true.
Sourcepub fn backoff_ms(self, ms: u64) -> Self
pub fn backoff_ms(self, ms: u64) -> Self
Fixed delay between retry attempts, in milliseconds.
Sourcepub fn proxy(self, url: impl Into<String>) -> Self
pub fn proxy(self, url: impl Into<String>) -> Self
Per-fetch upstream proxy URL for the HTTP path. Format:
http://user:pass@host:port or socks5://host:port. The SDK
never honors HTTP_PROXY/HTTPS_PROXY from the environment;
this method is the only way to route an HTTP-path fetch
through a proxy.
Sourcepub fn ca_cert(self, path: impl Into<PathBuf>) -> Self
pub fn ca_cert(self, path: impl Into<PathBuf>) -> Self
Path to a PEM file containing extra root CAs to trust for this fetch’s HTTP path. Stacks on top of the platform trust store; does not replace it.
Sourcepub fn tls_insecure(self, on: bool) -> Self
pub fn tls_insecure(self, on: bool) -> Self
Disable TLS certificate verification for this fetch’s HTTP path. Dangerous — leaves the connection open to MITM. Use only against known-self-signed staging environments.
Sourcepub fn method(self, m: impl Into<String>) -> Self
pub fn method(self, m: impl Into<String>) -> Self
HTTP method. Defaults to GET. Pass "POST", "PUT", etc.
Sourcepub fn body(self, data: impl Into<Vec<u8>>) -> Self
pub fn body(self, data: impl Into<Vec<u8>>) -> Self
Raw request body. Mutually exclusive with Self::form_field.
Sets the body bytes as-is; add Content-Type via
Self::header when needed.
Sourcepub fn form_field(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn form_field( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a form field. Mutually exclusive with Self::body. The
pipeline sends the fields as application/x-www-form-urlencoded
and sets the content-type header automatically.
Sourcepub fn capture_ws(self, on: bool) -> Self
pub fn capture_ws(self, on: bool) -> Self
Capture WebSocket frame payloads to
network-bodies/<request_id>.frames.jsonl during the browser path.
Sourcepub fn capture_sse(self, on: bool) -> Self
pub fn capture_sse(self, on: bool) -> Self
Capture SSE event payloads to
network-bodies/<request_id>.frames.jsonl during the browser path.
Sourcepub async fn send(self) -> Result<FetchResult, Error>
pub async fn send(self) -> Result<FetchResult, Error>
Execute the fetch, with retries when configured. Retries only
fire for errors carrying retryable: true; any other error
short-circuits immediately.
Sourcepub async fn send_detailed(self) -> Result<FetchResult, FetchError>
pub async fn send_detailed(self) -> Result<FetchResult, FetchError>
Execute the fetch and preserve the fetch trace on failure.
This is what the CLI uses to emit kind: "error" events with a
fetch-local trace without adding trace fields to the global Error.
Trait Implementations§
Source§impl Clone for FetchBuilder
impl Clone for FetchBuilder
Source§fn clone(&self) -> FetchBuilder
fn clone(&self) -> FetchBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more