diff --git a/akka-http-tests/src/test/scala/akka/http/coding/DeflateSpec.scala b/akka-http-tests/src/test/scala/akka/http/coding/DeflateSpec.scala index 3ee58e8bdb..d0ea56de8f 100644 --- a/akka-http-tests/src/test/scala/akka/http/coding/DeflateSpec.scala +++ b/akka-http-tests/src/test/scala/akka/http/coding/DeflateSpec.scala @@ -65,8 +65,8 @@ class DeflateSpec extends WordSpec with CodecSpecSupport { } } - def ourDeflate(bytes: ByteString): ByteString = Deflate.newCompressor.compressAndFinish(bytes) - def ourInflate(bytes: ByteString): ByteString = Deflate.newDecompressor.decompress(bytes) + def ourDeflate(bytes: ByteString): ByteString = Deflate.encode(bytes) + def ourInflate(bytes: ByteString): ByteString = Deflate.decode(bytes) def streamDeflate(bytes: ByteString) = { val output = new ByteArrayOutputStream() diff --git a/akka-http-tests/src/test/scala/akka/http/coding/GzipSpec.scala b/akka-http-tests/src/test/scala/akka/http/coding/GzipSpec.scala index 1cc333ece2..994cfb795a 100644 --- a/akka-http-tests/src/test/scala/akka/http/coding/GzipSpec.scala +++ b/akka-http-tests/src/test/scala/akka/http/coding/GzipSpec.scala @@ -103,8 +103,8 @@ class GzipSpec extends WordSpec with CodecSpecSupport { } def gzip(s: String) = ourGzip(ByteString(s, "UTF8")) - def ourGzip(bytes: ByteString): ByteString = Gzip.newCompressor.compressAndFinish(bytes) - def ourGunzip(bytes: ByteString): ByteString = Gzip.newDecompressor.decompressAndFinish(bytes) + def ourGzip(bytes: ByteString): ByteString = Gzip.encode(bytes) + def ourGunzip(bytes: ByteString): ByteString = Gzip.decode(bytes) lazy val corruptGzipContent = { val content = gzip("Hello").toArray diff --git a/akka-http/src/main/scala/akka/http/coding/Decoder.scala b/akka-http/src/main/scala/akka/http/coding/Decoder.scala index b0604b622c..75c1da3ce2 100644 --- a/akka-http/src/main/scala/akka/http/coding/Decoder.scala +++ b/akka-http/src/main/scala/akka/http/coding/Decoder.scala @@ -21,6 +21,8 @@ trait Decoder { def decodeData[T](t: T)(implicit mapper: DataMapper[T]): T = mapper.transformDataBytes(t, newDecodeTransfomer) + def decode(input: ByteString): ByteString = newDecompressor.decompressAndFinish(input) + def newDecompressor: Decompressor def newDecodeTransfomer(): Flow[ByteString, ByteString] = { diff --git a/akka-http/src/main/scala/akka/http/coding/Encoder.scala b/akka-http/src/main/scala/akka/http/coding/Encoder.scala index 39eb2ef484..9dce5febe4 100644 --- a/akka-http/src/main/scala/akka/http/coding/Encoder.scala +++ b/akka-http/src/main/scala/akka/http/coding/Encoder.scala @@ -4,7 +4,6 @@ package akka.http.coding -import java.io.ByteArrayOutputStream import akka.http.model._ import akka.http.util.StreamUtils import akka.util.ByteString @@ -24,6 +23,8 @@ trait Encoder { def encodeData[T](t: T)(implicit mapper: DataMapper[T]): T = mapper.transformDataBytes(t, newEncodeTransformer) + def encode(input: ByteString): ByteString = newCompressor.compressAndFinish(input) + def newCompressor: Compressor def newEncodeTransformer(): Flow[ByteString, ByteString] = {