Skip to content
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

Merged
merged 21 commits into from
Dec 16, 2024

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented Dec 5, 2024

Now using Compression classes for client response decoding.

Removed oej.client.GZIPContentDecoder, now using only oeh.http.GZIPContentDecoder where necessary.

@sbordet sbordet requested review from gregw, joakime and lorban December 5, 2024 12:38
@sbordet sbordet linked an issue Dec 5, 2024 that may be closed by this pull request
@sbordet
Copy link
Contributor Author

sbordet commented Dec 5, 2024

TODO

@sbordet sbordet force-pushed the fix/jetty-12.1.x/12612/client-compressors branch from d178751 to 4b56e24 Compare December 5, 2024 17:35
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>
@sbordet sbordet force-pushed the fix/jetty-12.1.x/12612/client-compressors branch from 72ee178 to 8abb27d Compare December 6, 2024 10:38
…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>
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>
@sbordet sbordet requested a review from joakime December 8, 2024 15:01
}

@ParameterizedTest
@ValueSource(strings = {"brotli", "gzip", "zstandard"})
Copy link
Contributor

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

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>
@sbordet sbordet requested a review from gregw December 9, 2024 20:55
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Copy link
Contributor

@gregw gregw left a 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

Copy link
Contributor

@gregw gregw left a 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>
@sbordet sbordet requested review from gregw and lorban December 9, 2024 23:08
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>

public abstract class DecoderSource implements Content.Source
public abstract class DecoderSource extends ContentSourceTransformer
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@@ -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;
Copy link
Contributor

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.

Copy link
Contributor Author

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-https 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;
Copy link
Contributor

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;
Copy link
Contributor

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>
@sbordet sbordet requested a review from lorban December 12, 2024 16:24
Copy link
Contributor

@lorban lorban left a 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.

Copy link
Contributor

@gregw gregw left a 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.

Comment on lines +2235 to +2237
case "brotli" -> "br";
case "gzip" -> "gzip";
case "zstandard" -> "zstd";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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";

Copy link
Contributor Author

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.

Copy link
Contributor

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>
@sbordet sbordet requested review from lorban and gregw December 13, 2024 11:52
…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>
Comment on lines +15 to +17
compression-brotli
compression-gzip
compression-zstandard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment on lines +2238 to +2247
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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@sbordet sbordet requested a review from gregw December 16, 2024 07:35
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet merged commit fc4ad94 into jetty-12.1.x Dec 16, 2024
10 checks passed
@sbordet sbordet deleted the fix/jetty-12.1.x/12612/client-compressors branch December 16, 2024 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Use Compression classes for client decoding
4 participants