All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gecko.GeckoCompressor.kt Maven / Gradle / Ivy

Go to download

Full network logging allowing users to browse entire calls via simple urls and more.

There is a newer version: 0.0.6
Show newest version
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