Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Corrupted response during compression #1089

Open
vans239 opened this issue Nov 30, 2015 · 0 comments
Open

Corrupted response during compression #1089

vans239 opened this issue Nov 30, 2015 · 0 comments

Comments

@vans239
Copy link

vans239 commented Nov 30, 2015

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 
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant