Expand description
HAR recording/replay (route_from_har).
This module parses HAR 1.2 files (the HTTP Archive format) and produces a set
of canned route responses. The [BrowserContext::route_from_har] call turns
each HAR entry into a context-level route handler that, on a matching request,
serves the recorded response via Route::fulfill and
lets non-matching requests fall through to the network.
§Scope
Replay is fully implemented. Recording (capturing live traffic into a new
HAR file) is deferred — HarRecorder exists as a thin writer that can append
entries, but wiring it into the live request stream of every page is not yet
done. See the report notes.
The parsing structs lean heavily on #[serde(default)] because real-world
HAR files are messy: fields are frequently missing or carry unexpected types.
Structs§
- Har
- The top-level HAR document:
{ "log": { ... } }. - HarContent
- Response body payload + mime.
- HarCookie
{ "name": "...", "value": "..." }cookie (comment/domain/etc tolerated).- HarCreator
log.creator/log.browser.- HarEntry
- One request/response pair.
- HarHeader
{ "name": "...", "value": "..." }header.- HarLog
- The
logobject. Onlyentriesis consulted for replay;creator/browser/pagesare tolerated but ignored. - HarPage
log.pages[*](page-level timing metadata). Parsed for tolerance only.- HarPost
Data request.postData.- HarQuery
{ "name": "...", "value": "..." }query parameter.- HarRecorder
- A minimal HAR recorder: builds a
Harin memory and can write it to disk. - HarRequest
- A recorded request.
- HarResponse
- A recorded response.
- HarRoute
- A single HAR-derived route: the request signature to match against and the canned response to serve.
- Route
From HarOptions - Options for
route_from_har, mirroring Playwright’sRouteFromHarOptions.
Functions§
- routes_
from_ har - Parse a HAR file from disk and produce one
HarRouteper usable entry.