-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #12612 - Use Compression classes for client decoding. #12613
Fixes #12612 - Use Compression classes for client decoding. #12613
Conversation
TODO
|
d178751
to
4b56e24
Compare
Now using Compression classes for client response decoding. Removed oej.client.GZIPContentDecoder, now using only oeh.http.GZIPContentDecoder where necessary. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…pression-common. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Updated tests that required client jars in a web application. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
… installing CompressionHandler. Deprecated gzip.mod in favor of compression-gzip.mod. Renamed `CompressionHandler.registerCompression()` because there are many other methods called `put*` in the class. Fixed `jetty-home/pom.xml` to generate the correct jetty-home. Added distribution tests. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
72ee178
to
8abb27d
Compare
…ing. * Fixed GzipEncoderSink, to finish deflating when last=true. * Enhanced logic in CompressionResponse, to skip by status code, content-type, content-encoding and empty content. * CompressionResponse does not need to implement Callback. * Added tests for CompressionHandler in ee11. * Code cleanups. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
...jetty-compression-gzip/src/main/java/org/eclipse/jetty/compression/gzip/GzipCompression.java
Outdated
Show resolved
Hide resolved
...ompression-server/src/main/java/org/eclipse/jetty/compression/server/CompressionHandler.java
Show resolved
Hide resolved
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
...ompression-server/src/main/java/org/eclipse/jetty/compression/server/CompressionHandler.java
Show resolved
Hide resolved
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"brotli", "gzip", "zstandard"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to test at least some combinations of multiple algorithms
...istribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java
Outdated
Show resolved
Hide resolved
...istribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java
Show resolved
Hide resolved
...jetty-compression/jetty-compression-server/src/main/config/modules/compression-zstandard.mod
Outdated
Show resolved
Hide resolved
...core/jetty-compression/jetty-compression-server/src/main/config/modules/compression-gzip.mod
Show resolved
Hide resolved
...re/jetty-compression/jetty-compression-server/src/main/config/modules/compression-brotli.mod
Outdated
Show resolved
Hide resolved
...jetty-compression/jetty-compression-server/src/main/config/modules/compression-zstandard.mod
Outdated
Show resolved
Hide resolved
Implemented usage of minCompressSize. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Updated test after implementing minCompressSize. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a couple of niggles
documentation/jetty/modules/programming-guide/pages/migration/12.0-to-12.1.adoc
Outdated
Show resolved
Hide resolved
documentation/jetty/modules/programming-guide/pages/migration/12.0-to-12.1.adoc
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a couple of niggles left, but I'd be OK to approve if we want to build a release.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
|
||
public abstract class DecoderSource implements Content.Source | ||
public abstract class DecoderSource extends ContentSourceTransformer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this class now go away since it doesn't do anything anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine if it remains, in case it needs something more specific to compression.
jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpReceiver.java
Show resolved
Hide resolved
jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpReceiver.java
Outdated
Show resolved
Hide resolved
...tty-client/src/test/java/org/eclipse/jetty/client/HttpClientContentDecoderFactoriesTest.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/content/ContentSourceTransformer.java
Outdated
Show resolved
Hide resolved
@@ -777,7 +777,7 @@ public static class GZIPContentTransformer implements ContentTransformer | |||
|
|||
private final List<ByteBuffer> buffers = new ArrayList<>(2); | |||
private final ContentTransformer transformer; | |||
private final ContentDecoder decoder; | |||
private final GZIPContentDecoder decoder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should set the field type as GZIPDecoder
to make it explicit that using this subclass is mandatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an internal implementation detail, like declaring Map
but then using HashMap
.
The key point here is that we could get rid of the jetty-client
's GZIPContentDecoder
and we can now use jetty-http
s version without problems.
@@ -777,7 +777,7 @@ public static class GZIPContentTransformer implements ContentTransformer | |||
|
|||
private final List<ByteBuffer> buffers = new ArrayList<>(2); | |||
private final ContentTransformer transformer; | |||
private final ContentDecoder decoder; | |||
private final GZIPContentDecoder decoder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type should be GZIPDecoder
.
@@ -777,7 +777,7 @@ public static class GZIPContentTransformer implements ContentTransformer | |||
|
|||
private final List<ByteBuffer> buffers = new ArrayList<>(2); | |||
private final ContentTransformer transformer; | |||
private final ContentDecoder decoder; | |||
private final GZIPContentDecoder decoder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type should be GZIPDecoder
.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last small thing you forgot in a test, otherwise LGTM.
...tty-client/src/test/java/org/eclipse/jetty/client/HttpClientContentDecoderFactoriesTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI failures look real.
Just a few niggles otherwise.
documentation/jetty/modules/programming-guide/pages/migration/12.0-to-12.1.adoc
Outdated
Show resolved
Hide resolved
case "brotli" -> "br"; | ||
case "gzip" -> "gzip"; | ||
case "zstandard" -> "zstd"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case "brotli" -> "br"; | |
case "gzip" -> "gzip"; | |
case "zstandard" -> "zstd"; | |
case "brotli" -> "br"; | |
case "gzip" -> "gzip"; | |
case "zstandard" -> "zstd"; | |
case "all" -> "br,compression-gzip,compression-zstd"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gregw I'm not sure what you exactly mean here.
You mean for "all" to have a Content-Encoding
with just br
as a valid value, and 2 other invalid values?
Or you meant all 3 valid values, so br, gzip, zstd
?
Also, I just read RFC 9110, and it is way more complicated to support the right encoding than we can write in a distribution test, so I think it's best to write more complicated cases in non-distribution tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just think we need at least one distribution test that enables all the compression at once. I'm OK if the test itself just sends a single algorithm in its accept header. We just need to check the modules and xmls do not clash somehow.
I do mean all 3 valid values, I was just hacking in the "compression-", but a more elegant solution is possible
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…ressors'. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
compression-brotli | ||
compression-gzip | ||
compression-zstandard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
case "all" -> "br;q=0.5, gzip;q=1, zstd;q=0.1"; | ||
default -> throw new IllegalArgumentException(); | ||
}; | ||
|
||
String expected = switch (compressionName) | ||
{ | ||
case "brotli" -> "br"; | ||
case "gzip" -> "gzip"; | ||
case "zstandard" -> "zstd"; | ||
case "all" -> "gzip"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Now using Compression classes for client response decoding.
Removed oej.client.GZIPContentDecoder, now using only oeh.http.GZIPContentDecoder where necessary.