-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Describe the bug
When using Quarkus REST and having a method that @Produces(MediaType.SERVER_SENT_EVENTS)
and also has the annotation @Compressed
, the HTTP response is not compressed.
Expected behavior
The response should have the Content-Encoding
header set to the used compression type and the content should be compressed accordingly.
Actual behavior
The response contains Transfer-Encoding
header set to chunked
and the content is uncompressed.
How to Reproduce?
There is a project for reproduction at https://github.com/mailq/quarkus-compressed
But a method like this should suffice:
@GET
@Produces(MediaType.SERVER_SENT_EVENTS)
@Compressed
@Path("stream")
public void helloStream(@Context SseEventSink sink) {
for (var i = 0; i < 1000; i++) {
var event = new OutboundSseEventImpl.BuilderImpl().data(String.class, "Hello from Quarkus REST").build();
sink.send(event);
}
sink.close();
}
Don't forget to configure Quarkus to actually use compression, add Brotli to the compressors and the corresponding Brotli4j native library.
use curl --compressed -Lv
or any current browser to access the endpoint and investigate the response and compression.
Output of uname -a
or ver
Linux mailq 6.8.0-83-generic #83-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 5 21:46:54 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
openjdk version "21.0.8" 2025-07-15
Quarkus version or git rev
2.6.4
Build tool (ie. output of mvnw --version
or gradlew --version
)
Gradle 9.0.0
Additional information
The other endpoint in the reproducer project with @Produces(MediaType.TEXT_PLAIN)
compresses as expected.
If you say that SSE can't be compressed because of reasons, then I can point to https://checkboxes.andersmurphy.com/ where the Server Sent Events are compressed with Brotli just fine.