Skip to main content

Module recorder

Module recorder 

Available on crate features http and std only.
Expand description

Streaming HAR recorder contracts and the built-in file recorder.

A custom backend implements both Recorder and StreamingRecorder, with a per-exchange type implementing RecorderSession. StreamingRecorder::start_http_recording receives the request metadata and a bounded BodyCaptureStream. The implementation should transfer that stream to a worker that drains it while the request continues, then return a session that correlates the request with its eventual response. Likewise, RecorderSession::record_response transfers response metadata and its live body stream to the backend. It must return once the backend has accepted the stream, rather than waiting for the body to finish. This lets a backend stream captures to a file, remote collector, or other storage without materializing complete HTTP bodies in memory.

For a WebSocket upgrade, the session can return a WebSocketCapture backed by a WebSocketCaptureRecorder. HARExportLayer stores this opaque handle in the successful HTTP handshake metadata. An explicitly installed Rama WebSocket HAR layer claims it, observes complete application messages, and releases it when the connection ends or recording stops. The handshake and WebSocket protocol engine remain independent of HAR serialization and storage.

A custom WebSocket backend implements WebSocketCaptureRecorder::record as an asynchronous &self operation. The future provides natural backpressure: it completes only after the backend has written the message or handed it to bounded storage. That future can be dropped before completion when its socket task is cancelled, so implementations must keep cancellation from corrupting their backend state. The backend decides whether it needs internal synchronization; the capture contract itself neither requires exclusive mutable access nor retains an in-memory message history. Returning None from RecorderSession::web_socket_capture records only the HTTP exchange.

Structs§

BodyCaptureStream
Bounded stream of body events observed while an HTTP body is forwarded.
FileRecorder
Recorder that creates one file per recording session.
FileRecorderSession
HarFilePath
Path to the HAR file that the FileRecorder is recording into.
HttpRequestCapture
Request metadata and its live body capture stream.
HttpResponseCapture
Response metadata and its live body capture stream.
LogMetaInfo
This object represents the root of exported data.
WebSocketCapture
Opaque WebSocket capture handle propagated through HTTP upgrade extensions.
WebSocketCaptureFuture
One in-flight asynchronous WebSocket capture operation.
WebSocketCaptureLease
WebSocket-lifetime view of a WebSocketCapture.

Traits§

Recorder
RecorderSession
One in-progress HTTP exchange owned by a Recorder.
StreamingRecorder
Recorder capable of consuming live HTTP bodies without materializing them.
WebSocketCaptureRecorder
Asynchronous recorder for complete Chromium-shaped WebSocket messages.