Skip to main content

FetchBuilder

Struct FetchBuilder 

Source
pub struct FetchBuilder { /* private fields */ }
Expand description

Builder for Client::fetch(...).send().await.

Implementations§

Source§

impl FetchBuilder

Source

pub fn render(self, mode: RenderMode) -> Self

Source

pub fn wait(self, w: Wait) -> Self

Source

pub fn timeout(self, d: Duration) -> Self

Source

pub fn readiness_idle_ms(self, ms: u64) -> Self

Source

pub fn readiness_stable_ms(self, ms: u64) -> Self

Source

pub fn readiness_min_text_bytes(self, bytes: u64) -> Self

Source

pub fn want<I: IntoIterator<Item = Artifact>>(self, items: I) -> Self

Source

pub fn tab(self, tab: TabId) -> Self

Source

pub fn keep_tab_open(self, keep: bool) -> Self

Keep a freshly-opened target open after the fetch (for human takeover).

Source

pub fn network_bodies(self, mode: NetworkBodies) -> Self

Source

pub fn network_body_max_bytes(self, n: u64) -> Self

Source

pub fn network_redact(self, on: bool) -> Self

Source

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.

Source

pub fn headers<I, K, V>(self, headers: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<String>,

Add multiple request headers.

Source

pub fn user_agent(self, value: impl Into<String>) -> Self

Override the browser/client user agent.

Source

pub fn cookie(self, name: impl Into<String>, value: impl Into<String>) -> Self

Add a request cookie as a name=value pair.

Source

pub fn cookie_full(self, cookie: FetchCookie) -> Self

Add a full cookie, including optional Domain/Path/Secure/HttpOnly/ SameSite/Max-Age/Expires attributes.

Source

pub fn cookies<I, K, V>(self, cookies: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<String>,

Add multiple request cookies as name=value pairs.

Source

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.

Source

pub fn out_dir(self, dir: impl Into<PathBuf>) -> Self

Source

pub fn cookie_jar(self, path: 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.

Source

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.

Source

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.

Source

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.

Source

pub fn backoff_ms(self, ms: u64) -> Self

Fixed delay between retry attempts, in milliseconds.

Source

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.

Source

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.

Source

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.

Source

pub fn method(self, m: impl Into<String>) -> Self

HTTP method. Defaults to GET. Pass "POST", "PUT", etc.

Source

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.

Source

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.

Source

pub fn capture_ws(self, on: bool) -> Self

Capture WebSocket frame payloads to network-bodies/<request_id>.frames.jsonl during the browser path.

Source

pub fn capture_sse(self, on: bool) -> Self

Capture SSE event payloads to network-bodies/<request_id>.frames.jsonl during the browser path.

Source

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.

Source

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 code: "error" envelopes with a fetch-local trace without adding trace fields to the global Error.

Trait Implementations§

Source§

impl Clone for FetchBuilder

Source§

fn clone(&self) -> FetchBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more