diff --git a/.changes/1695ebf6-1351-4555-8ab9-d90c91622549.json b/.changes/1695ebf6-1351-4555-8ab9-d90c91622549.json new file mode 100644 index 00000000..aaa52a58 --- /dev/null +++ b/.changes/1695ebf6-1351-4555-8ab9-d90c91622549.json @@ -0,0 +1,8 @@ +{ + "id": "1695ebf6-1351-4555-8ab9-d90c91622549", + "type": "feature", + "description": "Add `writeChunk` method to HttpStream", + "issues": [ + "https://github.com/awslabs/smithy-kotlin/issues/759" + ] +} \ No newline at end of file diff --git a/src/common/src/aws/sdk/kotlin/crt/http/HttpStream.kt b/src/common/src/aws/sdk/kotlin/crt/http/HttpStream.kt index 4c8df24a..475c5e0e 100644 --- a/src/common/src/aws/sdk/kotlin/crt/http/HttpStream.kt +++ b/src/common/src/aws/sdk/kotlin/crt/http/HttpStream.kt @@ -40,4 +40,11 @@ public interface HttpStream : Closeable { * Activate the client stream and start processing the request */ public fun activate() + + /** + * Send a chunk of data. You must call activate() before using this function. + * @param chunkData the chunk of data to send. this should be already formatted in the chunked transfer encoding. + * @param isFinalChunk represents if the chunk of data is the final chunk. if set to true, this will terminate the request stream. + */ + public fun writeChunk(chunkData: ByteArray, isFinalChunk: Boolean) } diff --git a/src/jvm/src/aws/sdk/kotlin/crt/http/HttpStreamJVM.kt b/src/jvm/src/aws/sdk/kotlin/crt/http/HttpStreamJVM.kt index 7d51670a..0972d488 100644 --- a/src/jvm/src/aws/sdk/kotlin/crt/http/HttpStreamJVM.kt +++ b/src/jvm/src/aws/sdk/kotlin/crt/http/HttpStreamJVM.kt @@ -19,4 +19,8 @@ internal class HttpStreamJVM(private val jniStream: HttpStreamJni) : HttpStream override fun activate() = jniStream.activate() override fun close() = jniStream.close() + + override fun writeChunk(chunkData: ByteArray, isFinalChunk: Boolean) { + jniStream.writeChunk(chunkData, isFinalChunk) + } }