Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass Extras to NetworkClient via NetworkRequest #2783

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions coil-network-core/api/android/coil-network-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ public final class coil3/network/NetworkHeaders$Companion {
}

public final class coil3/network/NetworkRequest {
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;)V
public synthetic fun <init> (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 <init> (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;Lcoil3/Extras;)V
public synthetic fun <init> (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;
Expand Down
6 changes: 4 additions & 2 deletions coil-network-core/api/coil-network-core.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,20 @@ final class coil3.network/NetworkHeaders { // coil3.network/NetworkHeaders|null[
}

final class coil3.network/NetworkRequest { // coil3.network/NetworkRequest|null[0]
constructor <init>(kotlin/String, kotlin/String = ..., coil3.network/NetworkHeaders = ..., coil3.network/NetworkRequestBody? = ...) // coil3.network/NetworkRequest.<init>|<init>(kotlin.String;kotlin.String;coil3.network.NetworkHeaders;coil3.network.NetworkRequestBody?){}[0]
constructor <init>(kotlin/String, kotlin/String = ..., coil3.network/NetworkHeaders = ..., coil3.network/NetworkRequestBody? = ..., coil3/Extras) // coil3.network/NetworkRequest.<init>|<init>(kotlin.String;kotlin.String;coil3.network.NetworkHeaders;coil3.network.NetworkRequestBody?;coil3.Extras){}[0]

final val body // coil3.network/NetworkRequest.body|{}body[0]
final fun <get-body>(): coil3.network/NetworkRequestBody? // coil3.network/NetworkRequest.body.<get-body>|<get-body>(){}[0]
final val extras // coil3.network/NetworkRequest.extras|{}extras[0]
final fun <get-extras>(): coil3/Extras // coil3.network/NetworkRequest.extras.<get-extras>|<get-extras>(){}[0]
final val headers // coil3.network/NetworkRequest.headers|{}headers[0]
final fun <get-headers>(): coil3.network/NetworkHeaders // coil3.network/NetworkRequest.headers.<get-headers>|<get-headers>(){}[0]
final val method // coil3.network/NetworkRequest.method|{}method[0]
final fun <get-method>(): kotlin/String // coil3.network/NetworkRequest.method.<get-method>|<get-method>(){}[0]
final val url // coil3.network/NetworkRequest.url|{}url[0]
final fun <get-url>(): kotlin/String // coil3.network/NetworkRequest.url.<get-url>|<get-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]
Expand Down
9 changes: 5 additions & 4 deletions coil-network-core/api/jvm/coil-network-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ public final class coil3/network/NetworkHeaders$Companion {
}

public final class coil3/network/NetworkRequest {
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;)V
public synthetic fun <init> (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 <init> (Ljava/lang/String;Ljava/lang/String;Lcoil3/network/NetworkHeaders;Lcoil3/network/NetworkRequestBody;Lcoil3/Extras;)V
public synthetic fun <init> (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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class NetworkFetcher(
method = options.httpMethod,
headers = headers.build(),
body = options.httpBody,
extras = options.extras,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class NetworkFetcherTest : RobolectricTest() {

assertIs<SourceFetchResult>(result)

val expected = NetworkRequest(url, method, headers, body)
val expected = NetworkRequest(url, method, headers, body, options.extras)

assertEquals(expected, networkClient.requests.single())
}
Expand Down