Skip to content
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
3 changes: 3 additions & 0 deletions okhttp/api/android/okhttp.api
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ public final class okhttp3/Headers : java/lang/Iterable, kotlin/jvm/internal/mar
public static final field EMPTY Lokhttp3/Headers;
public final fun -deprecated_size ()I
public final fun byteCount ()J
public final fun combine (Lokhttp3/Headers;)Lokhttp3/Headers;
public fun equals (Ljava/lang/Object;)Z
public final fun get (Ljava/lang/String;)Ljava/lang/String;
public final fun getDate (Ljava/lang/String;)Ljava/util/Date;
Expand Down Expand Up @@ -623,6 +624,8 @@ public final class okhttp3/Headers$Builder {
public final fun addUnsafeNonAscii (Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
public final fun build ()Lokhttp3/Headers;
public final fun get (Ljava/lang/String;)Ljava/lang/String;
public final synthetic fun minusAssign (Ljava/lang/String;)V
public final synthetic fun plusAssign (Lokhttp3/Headers;)V
public final fun removeAll (Ljava/lang/String;)Lokhttp3/Headers$Builder;
public final fun set (Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
public final fun set (Ljava/lang/String;Ljava/time/Instant;)Lokhttp3/Headers$Builder;
Expand Down
3 changes: 3 additions & 0 deletions okhttp/api/jvm/okhttp.api
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ public final class okhttp3/Headers : java/lang/Iterable, kotlin/jvm/internal/mar
public static final field EMPTY Lokhttp3/Headers;
public final fun -deprecated_size ()I
public final fun byteCount ()J
public final fun combine (Lokhttp3/Headers;)Lokhttp3/Headers;
public fun equals (Ljava/lang/Object;)Z
public final fun get (Ljava/lang/String;)Ljava/lang/String;
public final fun getDate (Ljava/lang/String;)Ljava/util/Date;
Expand Down Expand Up @@ -623,6 +624,8 @@ public final class okhttp3/Headers$Builder {
public final fun addUnsafeNonAscii (Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
public final fun build ()Lokhttp3/Headers;
public final fun get (Ljava/lang/String;)Ljava/lang/String;
public final synthetic fun minusAssign (Ljava/lang/String;)V
public final synthetic fun plusAssign (Lokhttp3/Headers;)V
public final fun removeAll (Ljava/lang/String;)Lokhttp3/Headers$Builder;
public final fun set (Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
public final fun set (Ljava/lang/String;Ljava/time/Instant;)Lokhttp3/Headers$Builder;
Expand Down
24 changes: 24 additions & 0 deletions okhttp/src/commonJvmAndroid/kotlin/okhttp3/Headers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ class Headers internal constructor(

fun newBuilder(): Builder = commonNewBuilder()

/**
* Returns a new headers instance that combines the headers of this instance with `other`. If
* this instance has no headers, then `other` is returned. If `other` has no headers, then this
* instance is returned. Otherwise, the headers of this instance followed by the headers of
* `other` are returned.
*/
@JvmName("combine")
operator fun plus(other: Headers): Headers =
when {
this.size == 0 -> other
other.size == 0 -> this
else -> Headers(this.namesAndValues + other.namesAndValues)
}

/**
* Returns true if `other` is a `Headers` object with the same headers, with the same casing, in
* the same order. Note that two headers instances may be *semantically* equal but not equal
Expand Down Expand Up @@ -260,6 +274,11 @@ class Headers internal constructor(
*/
fun addAll(headers: Headers) = commonAddAll(headers)

@JvmSynthetic
operator fun plusAssign(headers: Headers) {
addAll(headers)
}

/**
* Add a header with the specified name and formatted date. Does validation of header names and
* value.
Expand Down Expand Up @@ -306,6 +325,11 @@ class Headers internal constructor(

fun removeAll(name: String) = commonRemoveAll(name)

@JvmSynthetic
operator fun minusAssign(name: String) {
removeAll(name)
}

/**
* Set a field with the specified value. If the field is not found, it is added. If the field is
* found, the existing values are replaced.
Expand Down