gecko.GeckoCompressor.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gecko-core Show documentation
Show all versions of gecko-core Show documentation
Full network logging allowing users to browse entire calls via simple urls and more.
package gecko
import gecko.model.NetworkMetadata
import gecko.model.Tail
import gecko.model.mapBytes
import java.io.ByteArrayOutputStream
import java.util.zip.GZIPOutputStream
class GeckoCompressor(
private val source: Gecko
) : Gecko {
override fun process(metadata: NetworkMetadata): Tail = source.process(metadata)
.mapBytes(::compress)
private fun compress(bytes: ByteArray) = ByteArrayOutputStream(bytes.size).use { byteOutput ->
GZIPOutputStream(byteOutput).use { gzipOutput ->
gzipOutput.write(bytes)
gzipOutput.finish()
}
byteOutput.toByteArray()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy