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

Web server: Make brotli, deflate, gzip configurable #40692

Closed
Karm opened this issue May 17, 2024 · 3 comments · Fixed by #40750
Closed

Web server: Make brotli, deflate, gzip configurable #40692

Karm opened this issue May 17, 2024 · 3 comments · Fixed by #40750

Comments

@Karm
Copy link
Member

Karm commented May 17, 2024

Description

Sparkled by #40533

When http compression is enabled, Quarkus defaults to gzip, i.e. when faced with this request header:

> Accept-Encoding: deflate, gzip, br

it responds with gzipped content:

< content-encoding: gzip

Similarly, if the client claims only support for deflate, Quarkus obliges with deflate compressed content:

> Accept-Encoding: deflate
< content-encoding: deflate

Brotli compression is available via brotli4j JNI wrapper and it is a part of Vert.x and it could be used by Quarkus both in Native and HotSpot, see example project. The configuration is cumbersome and requires additional config in user's app. When configured, it works though:

> Accept-Encoding: deflate, gzip, br
< content-encoding: br

I'd like to add a new option, yet another knob to tune, alongside the existing options here:

quarkus.http.enable-compression=true
quarkus.http.compress-media-types=text/plain

I have this cooking now:


    /**
     * If user adds br, then brotli will be added to the list of supported compression algorithms.
     * It implies loading libbrotli native library via JNI and in case of Native image,
     * packing the native library into the native image as a resource thus inflating its size.
     * Note that a native shared object library must be available for your platform in Brotli4J project.
     */
    @ConfigItem(defaultValue = "gzip,deflate")
    public Optional<List<String>> compressionAlgorithms;

EDIT: Actually this does not handle well, because if you would like to remove e.g. deflate, it would require additional substitutions and tweaking in vert.x to actually remove it and that is a "feature" nobody asked for. So it would be much better to call it:

    public Optional<List<String>> addCompressors;

And now if it adds br as brotli, the Brotli compressor is added back to Vert.x, where it was removed in the first place in isBrotliAvailable.

...and a corresponding native build steps that would bake resources and init as needed so as user doesn't have to.

WIP...

Implementation ideas

No response

@Karm Karm added the kind/enhancement New feature or request label May 17, 2024
@Karm Karm self-assigned this May 17, 2024
Copy link

quarkus-bot bot commented May 17, 2024

/cc @radcortez (config), @zakkak (native-image)

@Karm Karm changed the title Web server compression: Make brotli, deflate, gzip configurable (HotSpot and Native) Web server: Make brotli, deflate, gzip configurable May 17, 2024
@Karm
Copy link
Member Author

Karm commented May 21, 2024

I have it implemented. Testing on non Linux amd64 platforms....

@melloware
Copy link
Contributor

Nice!

@quarkus-bot quarkus-bot bot added this to the 3.12 - main milestone Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants