spray
spray copied to clipboard
Corrupted response during compression
Encoder produces wrong compressed file in case of big files (multiple chunks)
object GzipTest extends App {
val file = new File("xxxx") //some big file
val bytes = IOUtils.toByteArray(new FileInputStream(file))
class Test extends HttpServiceActor {
override def receive: Receive = runRoute {
compressResponseIfRequested() {
path("a" / IntNumber) { n =>
complete(HttpEntity(ContentTypes.`application/json`, HttpData(bytes take n)))
} ~ path("b" / IntNumber) { n =>
complete(HttpEntity(ContentTypes.`application/json`, HttpData(file, 0, n)))
}
}
}
}
val system = ActorSystem()
//start actor
These commands will produce files with different sizes (first corrupred, second good)
wget -vS --header='Accept-encoding:gzip' localhost:.../b/131073
wget -vS --header='Accept-encoding:gzip' localhost:.../a/131073