@@ -52,9 +52,10 @@ public expect class GrpcMetadata constructor()
5252/* *
5353 * Returns the last metadata entry added with the given [key], or `null` if there are no entries.
5454 *
55- * @param key the name of the metadata entry to retrieve (case-insensitive). Must not end with `-bin`.
55+ * @param key the name of the metadata entry (case-insensitive). Must contain only digits (0-9),
56+ * lowercase letters (a-z), and special characters (`-`, `_`, `.`). Must not end with `-bin`.
5657 * @return the last value associated with the key, or `null` if no values exist
57- * @throws IllegalArgumentException if the key ends with `-bin`
58+ * @throws IllegalArgumentException if the key ends with `-bin` or contains invalid characters
5859 */
5960public expect operator fun GrpcMetadata.get (key : String ): String?
6061
@@ -63,18 +64,22 @@ public expect operator fun GrpcMetadata.get(key: String): String?
6364 *
6465 * Binary keys must end with the "-bin" suffix according to gRPC specification.
6566 *
66- * @param key the name of the binary metadata entry to retrieve (case-insensitive). Must end with `-bin`.
67+ * @param key the name of the metadata entry (case-insensitive).
68+ * Must contain only digits (0-9), lowercase letters (a-z), and special characters (`-`, `_`, `.`).
69+ * Must end with `-bin`.
6770 * @return the last binary value associated with the key, or `null` if no values exist
68- * @throws IllegalArgumentException if the key does not end with `-bin`
71+ * @throws IllegalArgumentException if the key does not end with `-bin` or contains invalid characters
6972 */
7073public expect fun GrpcMetadata.getBinary (key : String ): ByteArray?
7174
7275/* *
7376 * Returns all metadata entries with the given [key], in the order they were added.
7477 *
75- * @param key the name of the metadata entries to retrieve (case-insensitive). Must not end with `-bin`.
78+ * @param key the name of the metadata entry (case-insensitive).
79+ * Must contain only digits (0-9), lowercase letters (a-z), and special characters (`-`, `_`, `.`).
80+ * Must not end with `-bin`.
7681 * @return a list of all values associated with the key, or an empty list if no values exist
77- * @throws IllegalArgumentException if the key ends with `-bin`
82+ * @throws IllegalArgumentException if the key ends with `-bin` or contains invalid characters
7883 */
7984public expect fun GrpcMetadata.getAll (key : String ): List <String >
8085
@@ -83,9 +88,11 @@ public expect fun GrpcMetadata.getAll(key: String): List<String>
8388 *
8489 * Binary keys must end with the "-bin" suffix according to gRPC specification.
8590 *
86- * @param key the name of the binary metadata entries to retrieve (case-insensitive). Must end with `-bin`.
91+ * @param key the name of the metadata entry (case-insensitive).
92+ * Must contain only digits (0-9), lowercase letters (a-z), and special characters (`-`, `_`, `.`).
93+ * Must end with `-bin`.
8794 * @return a list of all binary values associated with the key, or an empty list if no values exist
88- * @throws IllegalArgumentException if the key does not end with `-bin`
95+ * @throws IllegalArgumentException if the key does not end with `-bin` or contains invalid characters
8996 */
9097public expect fun GrpcMetadata.getAllBinary (key : String ): List <ByteArray >
9198
@@ -102,7 +109,8 @@ public expect fun GrpcMetadata.keys(): Set<String>
102109/* *
103110 * Returns `true` if this metadata contains one or more values for the specified [key].
104111 *
105- * @param key the key whose presence is to be tested (case-insensitive)
112+ * @param key the key whose presence is to be tested (case-insensitive).
113+ * Must contain only digits (0-9), lowercase letters (a-z), and special characters (`-`, `_`, `.`).
106114 * @return `true` if this metadata contains the key, `false` otherwise
107115 */
108116public expect operator fun GrpcMetadata.contains (key : String ): Boolean
@@ -137,10 +145,12 @@ public expect fun GrpcMetadata.appendBinary(key: String, value: ByteArray)
137145/* *
138146 * Removes the first occurrence of the specified [value] for the given [key].
139147 *
140- * @param key the name of the metadata entry (case-insensitive). Must not end with `-bin`.
148+ * @param key the name of the metadata entry (case-insensitive).
149+ * Must contain only digits (0-9), lowercase letters (a-z), and special characters (`-`, `_`, `.`).
150+ * Must not end with `-bin`.
141151 * @param value the value to remove
142152 * @return `true` if the value was found and removed, `false` if the value was not present
143- * @throws IllegalArgumentException if the key ends with `-bin`
153+ * @throws IllegalArgumentException if the key ends with `-bin` or contains invalid characters
144154 */
145155public expect fun GrpcMetadata.remove (key : String , value : String ): Boolean
146156
@@ -149,7 +159,9 @@ public expect fun GrpcMetadata.remove(key: String, value: String): Boolean
149159 *
150160 * Binary keys must end with the "-bin" suffix according to gRPC specification.
151161 *
152- * @param key the name of the binary metadata entry (case-insensitive). Must end with `-bin`.
162+ * @param key the name of the binary metadata entry (case-insensitive).
163+ * Must contain only digits (0-9), lowercase letters (a-z), and special characters (`-`, `_`, `.`).
164+ * Must end with `-bin`.
153165 * @param value the binary value to remove
154166 * @return `true` if the value was found and removed, `false` if the value was not present
155167 * @throws IllegalArgumentException if the key does not end with `-bin`
@@ -159,7 +171,9 @@ public expect fun GrpcMetadata.removeBinary(key: String, value: ByteArray): Bool
159171/* *
160172 * Removes all values for the given [key] and returns them.
161173 *
162- * @param key the name of the metadata entries to remove (case-insensitive). Must not end with `-bin`.
174+ * @param key the name of the metadata entries to remove (case-insensitive).
175+ * Must contain only digits (0-9), lowercase letters (a-z), and special characters (`-`, `_`, `.`).
176+ * Must not end with `-bin`.
163177 * @return a list of all values that were removed, or an empty list if there were no values
164178 * @throws IllegalArgumentException if the key ends with `-bin`
165179 */
@@ -170,7 +184,9 @@ public expect fun GrpcMetadata.removeAll(key: String): List<String>
170184 *
171185 * Binary keys must end with the "-bin" suffix according to gRPC specification.
172186 *
173- * @param key the name of the binary metadata entries to remove (case-insensitive). Must end with `-bin`.
187+ * @param key the name of the binary metadata entries to remove (case-insensitive).
188+ * Must contain only digits (0-9), lowercase letters (a-z), and special characters (`-`, `_`, `.`).
189+ * Must end with `-bin`.
174190 * @return a list of all binary values that were removed, or an empty list if there were no values
175191 * @throws IllegalArgumentException if the key does not end with `-bin`
176192 */
0 commit comments