0

I have a ScalatraServlet as follows:

class MyServlet extends ScalatraServlet with FutureSupport with GZipSupport with JacksonJsonSupport {
..
}

When running, I get:

java.lang.IllegalStateException: STREAM

I've also tried adding a jetty filter as follows in my ScalatraBootstrap:

val gzip = context.addFilter("gzip-responses", classOf[NicsGzipFilter])
gzip.setInitParameter("mimeTypes", "text/html,text/plain,text/xml,application/json,application/xml,application/xhtml+xml,text/css,application/javascript,image/svg+xml")
gzip.setInitParameter("minGzipSize", "1") // TODO for testing only. Remove before committing
gzip.addMappingForUrlPatterns(java.util.EnumSet.allOf(classOf[DispatcherType]), true, "/*")
gzip.setAsyncSupported(true) // not sure if this is required?

In this case, I get responses, but they are not gzipped (although the jetty filter definitely runs because it adds a vary encoding header).

I seem to be getting the same error as reported here: ScalatraServlet with AkkaSupport with GZipSupport . So it doesn't look like the bug was fixed.

Another suggestion for why it's not working was made here: https://github.com/scalatra/scalatra/issues/247#issuecomment-12219667 . The suggestion is that Scalatra is calling outputting using a writer and output stream within the same response, which isn't allowed.

Any tips?

Thanks.

Community
  • 1
  • 1

1 Answers1

0

Chatted to rossabaker on IRC and after submitting a sample application which replicated the problem he identified the issue and came up with a fix: https://github.com/scalatra/scalatra/pull/316 .

It turns out the FutureSupport trait was not respecting the response wrapper generated by the GZipFilter.