intercept
abstract suspend fun <T> intercept(urlPattern: String, requestStage: Fetch.RequestStage, resourceType: Network.ResourceType, block: suspend FetchInterception.() -> T): T
Intercepts network requests matching the given urlPattern and requestStage. This allows you to modify requests, responses, or block them entirely.
Example usage:
tab.intercept("https://api.example.com/data", Fetch.RequestStage.RESPONSE, Network.ResourceType.XHR) {
tab.get("https://example.com")
// Can modify the request or response here, or intercept the body before it gets unavailable
val originalResponse = getResponseBody<UserData>()
continueRequest()
}
Content copied to clipboard