NetworkCaptureFilter

Decides whether a request is captured.

A host-supplied SPI that keeps traffic out of the Network tab, such as calls to an analytics host or requests the app marks with a header of its own. A request the filter skips is never stored, so it costs no redaction and no part of the capture budget. The filter affects capture only: mock rules and the throttle still apply to a skipped request, as they do while capture is paused. Use NoOpNetworkCaptureFilter for the default behaviour of capturing every request.

Once the filter skips a request, the Network tab shows an indicator, and its details show the description, so a teammate who sees fewer requests than expected can find out why. Build a filter from a lambda with of, or implement both members.

Lustro calls shouldCapture once per request, before it captures anything, on the thread that makes the call: an OkHttp call's thread, or the thread that uses an HttpURLConnection when platform capture is on. For a WebSocket from Lustro.webSocketFactory, it calls it once, on the thread that creates the socket, with the request the app passed; a socket the filter skips has neither its handshake nor a message captured. Keep it fast and thread-safe. A filter that throws doesn't fail the call: the request is captured, and Lustro logs the first failure only.

Types

Link copied to clipboard
object Companion

Factories for NetworkCaptureFilter.

Properties

Link copied to clipboard
abstract val description: String

What the filter leaves out, for a reader who hasn't seen its code, e.g. "Analytics calls, and requests marked X-No-Capture". Lustro reads it once, when the tab is created.

Functions

Link copied to clipboard

Returns true to capture request, or false to leave it out of the Network tab.