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

Implement de/compression in Http2ServerHandler #10660

Merged
merged 2 commits into from
Mar 28, 2024
Merged

Implement de/compression in Http2ServerHandler #10660

merged 2 commits into from
Mar 28, 2024

Conversation

yawkat
Copy link
Member

@yawkat yawkat commented Mar 28, 2024

  • Decompression implemented through DelegatingDecompressorFrameListener because backpressure is a bit awkward otherwise
  • Compression implemented through custom code because we need it for the compression config options we provide
  • Merged DecompressionSpec into CompressionSpec
  • Moved CompressionSpec to micronaut HTTP client (for HTTP/3 support)
  • Added subclasses of CompressionSpec for HTTP/2 and HTTP/3

Not scheduled to a project, it can go to 4.4 or 4.5 it doesn't matter

- Decompression implemented through DelegatingDecompressorFrameListener because backpressure is a bit awkward otherwise
- Compression implemented through custom code because we need it for the compression config options we provide
- Merged DecompressionSpec into CompressionSpec
- Moved CompressionSpec to micronaut HTTP client (for HTTP/3 support)
- Added subclasses of CompressionSpec for HTTP/2 and HTTP/3
@yawkat yawkat added the type: improvement A minor improvement to an existing feature label Mar 28, 2024
Copy link

sonarcloud bot commented Mar 28, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
54.7% Coverage on New Code (required ≥ 70%)

See analysis details on SonarCloud

@@ -52,6 +57,8 @@ final class Compressor {
private final SnappyOptions snappyOptions;

Compressor(HttpCompressionStrategy strategy) {
assert strategy.isEnabled();
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we raise a ConfigurationException instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's only a sanity check, the callers do not invoke the constructor at all in this case

if (!finished) {
try {
compressionChannel.finishAndReleaseAll();
} catch (DecompressionException ignored) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should not we log this exception?

Copy link
Member Author

Choose a reason for hiding this comment

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

this happens when a user closes a connection so we want to avoid log spam from half-finished data

@@ -92,6 +108,48 @@ class CompressionSpec extends Specification {
-1 | 10000 | false
}

def decompression(ChannelHandler compressor, CharSequence contentEncoding) {
given:
def ctx = ApplicationContext.run(['spec.name': 'CompressionSpec'] + serverOptions())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def ctx = ApplicationContext.run(['spec.name': 'CompressionSpec'] + serverOptions())
EmbeddedServer server = ApplicationContext.run(EmbeddedServer, ['spec.name': 'CompressionSpec'] + serverOptions())

def decompression(ChannelHandler compressor, CharSequence contentEncoding) {
given:
def ctx = ApplicationContext.run(['spec.name': 'CompressionSpec'] + serverOptions())
def server = ctx.getBean(EmbeddedServer).start()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def server = ctx.getBean(EmbeddedServer).start()

given:
def ctx = ApplicationContext.run(['spec.name': 'CompressionSpec'] + serverOptions())
def server = ctx.getBean(EmbeddedServer).start()
def client = ctx.createBean(HttpClient, server.URI).toBlocking()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def client = ctx.createBean(HttpClient, server.URI).toBlocking()
def client = server.applicationContext.createBean(HttpClient, server.URI).toBlocking()

cleanup:
client.close()
server.stop()
ctx.close()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ctx.close()
server.close()


cleanup:
client.close()
server.stop()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
server.stop()

@sdelamo sdelamo merged commit 036f48b into 4.4.x Mar 28, 2024
16 of 17 checks passed
@sdelamo sdelamo deleted the h2-compression branch March 28, 2024 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants