From 43316411c9779000fc8e7fd4481cff3c5f9024ae Mon Sep 17 00:00:00 2001 From: NathanFallet Date: Tue, 19 Aug 2025 11:46:30 +0200 Subject: [PATCH] feat: add FetchInterception getRequest method (same as RequestExpectation) --- .../kotlin/dev/kdriver/core/network/BaseFetchInterception.kt | 2 ++ .../kotlin/dev/kdriver/core/network/FetchInterception.kt | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/core/src/commonMain/kotlin/dev/kdriver/core/network/BaseFetchInterception.kt b/core/src/commonMain/kotlin/dev/kdriver/core/network/BaseFetchInterception.kt index 22ff2aeb7..dc7656618 100644 --- a/core/src/commonMain/kotlin/dev/kdriver/core/network/BaseFetchInterception.kt +++ b/core/src/commonMain/kotlin/dev/kdriver/core/network/BaseFetchInterception.kt @@ -54,6 +54,8 @@ open class BaseFetchInterception( override suspend fun getRequestEvent(): Fetch.RequestPausedParameter = responseDeferred.await() + override suspend fun getRequest(): Network.Request = getRequestEvent().request + override suspend fun getRawResponseBody(): EncodedBody { val requestId = getRequestEvent().requestId return EncodedBody(tab.fetch.getResponseBody(requestId)) diff --git a/core/src/commonMain/kotlin/dev/kdriver/core/network/FetchInterception.kt b/core/src/commonMain/kotlin/dev/kdriver/core/network/FetchInterception.kt index 40e308ab8..888d09dbb 100644 --- a/core/src/commonMain/kotlin/dev/kdriver/core/network/FetchInterception.kt +++ b/core/src/commonMain/kotlin/dev/kdriver/core/network/FetchInterception.kt @@ -30,6 +30,11 @@ interface FetchInterception { */ suspend fun getRequestEvent(): Fetch.RequestPausedParameter + /** + * Returns the request once it has been received. + */ + suspend fun getRequest(): Network.Request + /** * Fetches the raw response body once it has been received. */