Skip to main content

Module network

Module network 

Source
Expand description

Network lifecycle objects: Request, Response, WebSocket.

Mirrors Playwright’s client-side Request / Response / WebSocket classes from packages/playwright-core/src/client/network.ts. Live object references — listeners hold a Request and can call request.response().await later; the future resolves when the response (or failure) is recorded by the backend.

Each lifecycle object wraps an Arc<RequestState> / Arc<ResponseState> / Arc<WebSocketState>. The same Arc is held by the per-page network listener loop on every backend; backend events mutate the inner state through the lock and notify waiters.

Structs§

HeaderEntry
Single header entry preserving original case and duplicate keys.
NavRequestSlot
Shared slot for the most recent main-document navigation Request.
RemoteAddr
Server IP + port. Resolved from CDP responseReceived.response.remoteIPAddress.
Request
Live reference to a network request. Mirrors Playwright’s Request.
RequestInit
Construction parameters for a new Request.
RequestSizes
Body / header byte counts for a completed request. Field names mirror Playwright’s RequestSizes over the wire (camelCase via serde rename); the Rust field identifiers drop the _size suffix so they read cleanly at call sites without all four sharing a postfix.
RequestTiming
Resource timing in milliseconds since startTime. Sentinel values: start_time is wall-clock ms (Unix epoch), every other field is -1.0 when not measured (matches Playwright’s ResourceTiming).
Response
ResponseInit
SecurityDetails
TLS certificate info. Resolved from CDP responseReceived.response.securityDetails.
WebSocket

Enums§

WebSocketEvent
WebSocketPayload
WebSocket payload — text frames stay as String, binary frames carry bytes.

Functions§

body_unsupported
Returns a BodyFn that reports the operation as unsupported. Kept as a typed fallback for any request whose backend genuinely can’t expose its body. (The Playwright WebKit backend fetches bodies via Network.getResponseBody, so it does not use this.)
get_header_value
headers_array_to_map
headers_to_array

Type Aliases§

BodyFn
Backend-supplied async closure that fetches a response body lazily. Used by Response::body() so the actual Network.getResponseBody (CDP) / network.fetchBodyBytes (BiDi) round-trip happens on demand, not as part of every responseReceived event.
Headers
Header map. Lower-case-keyed combined view (matches Playwright’s headers(): Headers shape).
RawHeadersFn
Backend-supplied async closure that fetches actual headers (after HSTS, cookie injection, redirects). CDP delivers them via push event; for backends without push, the Response calls this lazily.