jooby-project / jooby

The modular web framework for Java and Kotlin
https://jooby.io
Apache License 2.0
1.7k stars 199 forks source link

How does Jooby handle gzip encoding for requests and responses? #3443

Closed nonetallt closed 4 months ago

nonetallt commented 4 months ago

From the documentation, I noticed that ServerOptions has a method called setCompressionLevel.

The documentation from the javadoc for the method is as such:

Set compression level to use while producing gzip responses. Gzip is off by default (compression level is null).

This raises some questions regarding the gzip support:

1) When compression level has a non-null value, are all responses encoded or only ones for requests that have an accept-encoding: gzip header?

2) Can Jooby automatically decode incoming requests with a content-encoding: gzip header? If not, what is the recommended way of achieving this? My current solution is to read from input stream produced by GZIPInputStream(context.body().stream())) but I have a suspicion that the performance of this approach isn't ideal.

PS. I'm using netty as the underlying server in case that's relevant.

jknack commented 4 months ago

Hi

  1. Only the one that request gzip: accept-encoding: gzip
  2. there is nothing built in for gzip requests
nonetallt commented 4 months ago

Hi

1. Only the one that request gzip: `accept-encoding: gzip`

2. there is nothing built in for gzip requests

Thank you for the clarification.