From ffeaac9d7ba9ccdaea1e78430fdc5a24035f726d Mon Sep 17 00:00:00 2001 From: HeroBrine1st Erquilenne Date: Wed, 8 Jan 2025 20:46:47 +0300 Subject: [PATCH] Pass Extras to NetworkClient --- coil-network-core/api/android/coil-network-core.api | 9 +++++---- coil-network-core/api/coil-network-core.klib.api | 6 ++++-- coil-network-core/api/jvm/coil-network-core.api | 9 +++++---- .../src/commonMain/kotlin/coil3/network/NetworkClient.kt | 4 ++++ .../commonMain/kotlin/coil3/network/NetworkFetcher.kt | 1 + .../kotlin/coil3/network/NetworkFetcherTest.kt | 2 +- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/coil-network-core/api/android/coil-network-core.api b/coil-network-core/api/android/coil-network-core.api index 4e920ade60..b9013c8a1e 100644 --- a/coil-network-core/api/android/coil-network-core.api +++ b/coil-network-core/api/android/coil-network-core.api @@ -111,12 +111,13 @@ public final class coil3/network/NetworkHeaders$Companion { } public final class coil3/network/NetworkRequest { - public fun (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun copy (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;)Lcoil3/network/NetworkRequest; - public static synthetic fun copy$default (Lcoil3/network/NetworkRequest;Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;ILjava/lang/Object;)Lcoil3/network/NetworkRequest; + public fun (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;Lcoil3/Extras;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;Lcoil3/Extras;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun copy (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;Lcoil3/Extras;)Lcoil3/network/NetworkRequest; + public static synthetic fun copy$default (Lcoil3/network/NetworkRequest;Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;Lcoil3/Extras;ILjava/lang/Object;)Lcoil3/network/NetworkRequest; public fun equals (Ljava/lang/Object;)Z public final fun getBody ()Lcoil3/network/NetworkRequestBody; + public final fun getExtras ()Lcoil3/Extras; public final fun getHeaders ()Lcoil3/network/NetworkHeaders; public final fun getMethod ()Ljava/lang/String; public final fun getUrl ()Ljava/lang/String; diff --git a/coil-network-core/api/coil-network-core.klib.api b/coil-network-core/api/coil-network-core.klib.api index b7b3133389..2d2670a478 100644 --- a/coil-network-core/api/coil-network-core.klib.api +++ b/coil-network-core/api/coil-network-core.klib.api @@ -114,10 +114,12 @@ final class coil3.network/NetworkHeaders { // coil3.network/NetworkHeaders|null[ } final class coil3.network/NetworkRequest { // coil3.network/NetworkRequest|null[0] - constructor (kotlin/String, kotlin/String = ..., coil3.network/NetworkHeaders = ..., coil3.network/NetworkRequestBody? = ...) // coil3.network/NetworkRequest.|(kotlin.String;kotlin.String;coil3.network.NetworkHeaders;coil3.network.NetworkRequestBody?){}[0] + constructor (kotlin/String, kotlin/String = ..., coil3.network/NetworkHeaders = ..., coil3.network/NetworkRequestBody? = ..., coil3/Extras) // coil3.network/NetworkRequest.|(kotlin.String;kotlin.String;coil3.network.NetworkHeaders;coil3.network.NetworkRequestBody?;coil3.Extras){}[0] final val body // coil3.network/NetworkRequest.body|{}body[0] final fun (): coil3.network/NetworkRequestBody? // coil3.network/NetworkRequest.body.|(){}[0] + final val extras // coil3.network/NetworkRequest.extras|{}extras[0] + final fun (): coil3/Extras // coil3.network/NetworkRequest.extras.|(){}[0] final val headers // coil3.network/NetworkRequest.headers|{}headers[0] final fun (): coil3.network/NetworkHeaders // coil3.network/NetworkRequest.headers.|(){}[0] final val method // coil3.network/NetworkRequest.method|{}method[0] @@ -125,7 +127,7 @@ final class coil3.network/NetworkRequest { // coil3.network/NetworkRequest|null[ final val url // coil3.network/NetworkRequest.url|{}url[0] final fun (): kotlin/String // coil3.network/NetworkRequest.url.|(){}[0] - final fun copy(kotlin/String = ..., kotlin/String = ..., coil3.network/NetworkHeaders = ..., coil3.network/NetworkRequestBody? = ...): coil3.network/NetworkRequest // coil3.network/NetworkRequest.copy|copy(kotlin.String;kotlin.String;coil3.network.NetworkHeaders;coil3.network.NetworkRequestBody?){}[0] + final fun copy(kotlin/String = ..., kotlin/String = ..., coil3.network/NetworkHeaders = ..., coil3.network/NetworkRequestBody? = ..., coil3/Extras = ...): coil3.network/NetworkRequest // coil3.network/NetworkRequest.copy|copy(kotlin.String;kotlin.String;coil3.network.NetworkHeaders;coil3.network.NetworkRequestBody?;coil3.Extras){}[0] final fun equals(kotlin/Any?): kotlin/Boolean // coil3.network/NetworkRequest.equals|equals(kotlin.Any?){}[0] final fun hashCode(): kotlin/Int // coil3.network/NetworkRequest.hashCode|hashCode(){}[0] final fun toString(): kotlin/String // coil3.network/NetworkRequest.toString|toString(){}[0] diff --git a/coil-network-core/api/jvm/coil-network-core.api b/coil-network-core/api/jvm/coil-network-core.api index 08eb3c8214..f0ba3f3ad0 100644 --- a/coil-network-core/api/jvm/coil-network-core.api +++ b/coil-network-core/api/jvm/coil-network-core.api @@ -111,12 +111,13 @@ public final class coil3/network/NetworkHeaders$Companion { } public final class coil3/network/NetworkRequest { - public fun (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun copy (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;)Lcoil3/network/NetworkRequest; - public static synthetic fun copy$default (Lcoil3/network/NetworkRequest;Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;ILjava/lang/Object;)Lcoil3/network/NetworkRequest; + public fun (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;Lcoil3/Extras;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;Lcoil3/Extras;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun copy (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;Lcoil3/Extras;)Lcoil3/network/NetworkRequest; + public static synthetic fun copy$default (Lcoil3/network/NetworkRequest;Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;Lcoil3/Extras;ILjava/lang/Object;)Lcoil3/network/NetworkRequest; public fun equals (Ljava/lang/Object;)Z public final fun getBody ()Lcoil3/network/NetworkRequestBody; + public final fun getExtras ()Lcoil3/Extras; public final fun getHeaders ()Lcoil3/network/NetworkHeaders; public final fun getMethod ()Ljava/lang/String; public final fun getUrl ()Ljava/lang/String; diff --git a/coil-network-core/src/commonMain/kotlin/coil3/network/NetworkClient.kt b/coil-network-core/src/commonMain/kotlin/coil3/network/NetworkClient.kt index 634a363726..b31e6f7ad9 100644 --- a/coil-network-core/src/commonMain/kotlin/coil3/network/NetworkClient.kt +++ b/coil-network-core/src/commonMain/kotlin/coil3/network/NetworkClient.kt @@ -1,5 +1,6 @@ package coil3.network +import coil3.Extras import coil3.annotation.Poko import coil3.network.internal.HTTP_METHOD_GET import coil3.network.internal.HTTP_RESPONSE_OK @@ -34,17 +35,20 @@ class NetworkRequest( val method: String = HTTP_METHOD_GET, val headers: NetworkHeaders = NetworkHeaders.EMPTY, val body: NetworkRequestBody? = null, + val extras: Extras ) { fun copy( url: String = this.url, method: String = this.method, headers: NetworkHeaders = this.headers, body: NetworkRequestBody? = this.body, + extras: Extras = this.extras ) = NetworkRequest( url = url, method = method, headers = headers, body = body, + extras = extras ) } diff --git a/coil-network-core/src/commonMain/kotlin/coil3/network/NetworkFetcher.kt b/coil-network-core/src/commonMain/kotlin/coil3/network/NetworkFetcher.kt index 32b7eda936..bd37f2cc6a 100644 --- a/coil-network-core/src/commonMain/kotlin/coil3/network/NetworkFetcher.kt +++ b/coil-network-core/src/commonMain/kotlin/coil3/network/NetworkFetcher.kt @@ -184,6 +184,7 @@ class NetworkFetcher( method = options.httpMethod, headers = headers.build(), body = options.httpBody, + extras = options.extras ) } diff --git a/coil-network-core/src/commonTest/kotlin/coil3/network/NetworkFetcherTest.kt b/coil-network-core/src/commonTest/kotlin/coil3/network/NetworkFetcherTest.kt index 57e7d068de..3c44e7275b 100644 --- a/coil-network-core/src/commonTest/kotlin/coil3/network/NetworkFetcherTest.kt +++ b/coil-network-core/src/commonTest/kotlin/coil3/network/NetworkFetcherTest.kt @@ -49,7 +49,7 @@ class NetworkFetcherTest : RobolectricTest() { assertIs(result) - val expected = NetworkRequest(url, method, headers, body) + val expected = NetworkRequest(url, method, headers, body, options.extras) assertEquals(expected, networkClient.requests.single()) }