Skip to content

Commit 15d5e93

Browse files
authored
feat: add writeChunk method to HttpStream (#61)
1 parent e027700 commit 15d5e93

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "1695ebf6-1351-4555-8ab9-d90c91622549",
3+
"type": "feature",
4+
"description": "Add `writeChunk` method to HttpStream",
5+
"issues": [
6+
"https://github.com/awslabs/smithy-kotlin/issues/759"
7+
]
8+
}

src/common/src/aws/sdk/kotlin/crt/http/HttpStream.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,11 @@ public interface HttpStream : Closeable {
4040
* Activate the client stream and start processing the request
4141
*/
4242
public fun activate()
43+
44+
/**
45+
* Send a chunk of data. You must call activate() before using this function.
46+
* @param chunkData the chunk of data to send. this should be already formatted in the chunked transfer encoding.
47+
* @param isFinalChunk represents if the chunk of data is the final chunk. if set to true, this will terminate the request stream.
48+
*/
49+
public fun writeChunk(chunkData: ByteArray, isFinalChunk: Boolean)
4350
}

src/jvm/src/aws/sdk/kotlin/crt/http/HttpStreamJVM.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ internal class HttpStreamJVM(private val jniStream: HttpStreamJni) : HttpStream
1919
override fun activate() = jniStream.activate()
2020

2121
override fun close() = jniStream.close()
22+
23+
override fun writeChunk(chunkData: ByteArray, isFinalChunk: Boolean) {
24+
jniStream.writeChunk(chunkData, isFinalChunk)
25+
}
2226
}

0 commit comments

Comments
 (0)