Skip to content

Conversation

@joewyz
Copy link
Contributor

@joewyz joewyz commented Dec 6, 2025

This PR added a new plugin to process request compression if @requestCompression trait is applied. With this feature, those protocol tests regarding content-encoding can pass now.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@sugmanue
Copy link
Contributor

More in general, can you please use consistently var. There're several uses of all var, all regular declarations, and everything in between.

import java.io.InputStream;
import java.util.zip.GZIPOutputStream;

final class GzipCompressingInputStream extends InputStream {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add javadoc.

Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation underneath still reads the whole input stream into memory to do the compression.

Comment on lines 33 to 34
if (available <= 0)
return -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use brackets.

Comment on lines 45 to 47
try (GZIPOutputStream gzip = new GZIPOutputStream(buffer)) {
source.transferTo(gzip);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This reads all the contents from source and transfers them to the gzip output stream.

CompressionAlgorithm.supportedAlgorithms();

@Override
public <RequestT> RequestT modifyBeforeTransmit(RequestHook<?, ?, RequestT> hook) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use here modifyBeforeRetryLoop instead. We want to compress only once instead of for each retry.

Also, we need to make sure that compression and streaming plays well with retries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants