GrpcMetadata
Available in a dev version: 0․11․0-grpc-186
How to configure
Provides access to read and write metadata values to be exchanged during a gRPC call.
Metadata is an ordered map with case-insensitive keys that are ASCII strings. Each key can be associated with multiple values. Values can be either strings (for standard keys) or binary data (for keys ending with "-bin" suffix).
Key Requirements
Keys must contain only the following ASCII characters:
Digits:
0-9Lowercase letters:
a-z(uppercase letters are normalized to lowercase)Special characters:
-,_,.
Keys must not contain spaces or other special characters. Invalid keys will cause an IllegalArgumentException to be thrown. Binary keys must additionally end with the -bin suffix.
Value Requirements
ASCII string values must contain only:
ASCII visible characters (0x21-0x7E)
Space (0x20), but not at the beginning or end of the string
Non-ASCII characters in values are replaced with ? during encoding.
Thread Safety
This class is not thread-safe. Modifications made by one thread may not be visible to another thread concurrently reading the metadata.
Example usage
val metadata = GrpcMetadata {
append("custom-header", "value1")
append("custom-header", "value2")
appendBinary("custom-header-bin", byteArrayOf(1, 2, 3))
}
val firstValue = metadata["custom-header"] // returns "value2" (last added)
val allValues = metadata.getAll("custom-header") // returns ["value1", "value2"]Provides access to read and write metadata values to be exchanged during a gRPC call.
Metadata is an ordered map with case-insensitive keys that are ASCII strings. Each key can be associated with multiple values. Values can be either strings (for standard keys) or binary data (for keys ending with "-bin" suffix).
Key Requirements
Keys must contain only the following ASCII characters:
Digits:
0-9Lowercase letters:
a-z(uppercase letters are normalized to lowercase)Special characters:
-,_,.
Keys must not contain spaces or other special characters. Invalid keys will cause an IllegalArgumentException to be thrown. Binary keys must additionally end with the -bin suffix.
Value Requirements
ASCII string values must contain only:
ASCII visible characters (0x21-0x7E)
Space (0x20), but not at the beginning or end of the string
Non-ASCII characters in values are replaced with ? during encoding.
Thread Safety
This class is not thread-safe. Modifications made by one thread may not be visible to another thread concurrently reading the metadata.
Example usage
val metadata = GrpcMetadata {
append("custom-header", "value1")
append("custom-header", "value2")
appendBinary("custom-header-bin", byteArrayOf(1, 2, 3))
}
val firstValue = metadata["custom-header"] // returns "value2" (last added)
val allValues = metadata.getAll("custom-header") // returns ["value1", "value2"]Provides access to read and write metadata values to be exchanged during a gRPC call.
Metadata is an ordered map with case-insensitive keys that are ASCII strings. Each key can be associated with multiple values. Values can be either strings (for standard keys) or binary data (for keys ending with "-bin" suffix).
Key Requirements
Keys must contain only the following ASCII characters:
Digits:
0-9Lowercase letters:
a-z(uppercase letters are normalized to lowercase)Special characters:
-,_,.
Keys must not contain spaces or other special characters. Invalid keys will cause an IllegalArgumentException to be thrown. Binary keys must additionally end with the -bin suffix.
Value Requirements
ASCII string values must contain only:
ASCII visible characters (0x21-0x7E)
Space (0x20), but not at the beginning or end of the string
Non-ASCII characters in values are replaced with ? during encoding.
Thread Safety
This class is not thread-safe. Modifications made by one thread may not be visible to another thread concurrently reading the metadata.
Example usage
val metadata = GrpcMetadata {
append("custom-header", "value1")
append("custom-header", "value2")
appendBinary("custom-header-bin", byteArrayOf(1, 2, 3))
}
val firstValue = metadata["custom-header"] // returns "value2" (last added)
val allValues = metadata.getAll("custom-header") // returns ["value1", "value2"]Constructors
Functions
Creates a copy of this metadata containing all entries.
Returns the last metadata entry added with the given key, or null if there are no entries.
Returns the last metadata entry added with the given typed key, or null if there are no entries.
Returns the last metadata entry added with the given key, or null if there are no entries.
Returns the last metadata entry added with the given typed key, or null if there are no entries.
Returns all metadata entries with the given key, in the order they were added.
Returns all metadata entries with the given typed key, in the order they were added.
Returns all metadata entries with the given key, in the order they were added.
Returns all metadata entries with the given typed key, in the order they were added.
Returns all binary metadata entries with the given key, in the order they were added.
Returns all binary metadata entries with the given typed key, in the order they were added.
Returns all binary metadata entries with the given key, in the order they were added.
Returns all binary metadata entries with the given typed key, in the order they were added.
Returns the last binary metadata entry added with the given key, or null if there are no entries.
Returns the last binary metadata entry added with the given typed key, or null if there are no entries.
Returns the last binary metadata entry added with the given key, or null if there are no entries.
Returns the last binary metadata entry added with the given typed key, or null if there are no entries.
Returns an immutable set of all keys present in this metadata.
Returns an immutable set of all keys present in this metadata.
Returns an immutable set of all keys present in this metadata.
Creates a new metadata instance containing all entries from this metadata and other.
Merges all entries from other metadata into this metadata using the += operator.
Removes all values for the given key and returns them.
Removes all values for the given typed key and returns them.
Removes all values for the given key and returns them.
Removes all values for the given typed key and returns them.