Skip to content

Commit f3b8e7f

Browse files
committed
Update Gzip ByteStream.Buffer compression
1 parent 755cc4b commit f3b8e7f

File tree

1 file changed

+5
-8
lines changed
  • runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/compression

1 file changed

+5
-8
lines changed

runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/compression/GzipNative.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
*/
55
package aws.smithy.kotlin.runtime.compression
66

7-
import aws.sdk.kotlin.crt.use
87
import aws.smithy.kotlin.runtime.content.ByteStream
98
import aws.smithy.kotlin.runtime.content.asByteStream
109
import aws.smithy.kotlin.runtime.io.GzipByteReadChannel
1110
import aws.smithy.kotlin.runtime.io.GzipSdkSource
1211
import aws.smithy.kotlin.runtime.io.SdkByteReadChannel
1312
import aws.smithy.kotlin.runtime.io.SdkSource
13+
import aws.smithy.kotlin.runtime.io.readToByteArray
14+
import aws.smithy.kotlin.runtime.io.source
1415
import kotlinx.coroutines.runBlocking
1516

1617
/**
@@ -37,16 +38,12 @@ public actual class Gzip : CompressionAlgorithm {
3738
}
3839

3940
is ByteStream.Buffer -> {
40-
val sourceBytes = stream.bytes()
41-
if (sourceBytes.isEmpty()) {
41+
val bytes = stream.bytes()
42+
if (bytes.isEmpty()) {
4243
stream
4344
} else {
4445
runBlocking {
45-
GzipCompressor().use {
46-
it.apply {
47-
update(sourceBytes)
48-
}.flush()
49-
}.asByteStream()
46+
GzipSdkSource(bytes.source()).readToByteArray().asByteStream()
5047
}
5148
}
5249
}

0 commit comments

Comments
 (0)