I have configured server.compression.enabled=true
for text/html
mime types, that are generated with freemarker
template. The rest of resources are compressed at built time (vite).
Testing over http
works as expected while activating http2
the compression just does not work.
Is this an error or I'm missing something?
Comment From: rstoyanchev
Similar to #26056 which is also for http2 and compression but for the client side, I think this is likely an issue for Reactor Netty. @userquin any chance that you can provide a small sample application?
Comment From: userquin
@rstoyanchev I'll try to provide a working sample, it seems to be a problem on the netty configuration, exactly on reactor.netty.http.server.HttpServerConfig::HttpServerChannelInitializer::onChannelInit::799
. If you see http
entry on this method, the compression predicate is added (http1.1
and/or h2
and/or h2c
), while on alone h2
or h2c
no. I'll try to add http1.1
and so redirecting to https
and see if it works, but I think it will not work.
I think it is a problem how http2
headers must be handled (hpack compression).
else if ((protocols & h2) == h2) {
configureH2Pipeline(
channel.pipeline(),
cookieDecoder,
cookieEncoder,
forwardedHeaderHandler,
http2Settings,
observer,
mapHandle,
opsFactory,
decoder.validateHeaders());
}
while for exmaple http1.1
entry ():
else if ((protocols & h11) == h11) {
configureHttp11Pipeline(
channel.pipeline(),
compressPredicate(compressPredicate, minCompressionSize), // <==== HERE THE DIFFERENCE
cookieDecoder,
cookieEncoder,
decoder,
forwardedHeaderHandler,
observer,
mapHandle,
metricsRecorder,
minCompressionSize,
uriTagValue);
}
Comment From: rstoyanchev
Okay at this point, might as well re-create the issue in https://github.com/reactor/reactor-netty. I wish I could transfer it but unfortunately it's not possible across organizations.
Comment From: userquin
@rstoyanchev this is a simple project:
spring-framework-issue-26018.zip
Just open it and see application.yml
inside resources
directory.
To run the app, just run main from SpringFrameworkIssue26018Application.kt
: open a browser and enter:
http://localhost:8080/index.html
To serve https (http1.1) you will need to install resources/localhost.crt
as a CA or just ignore the errors from the browser and run the app with -Dspring.profiles.active=https
or if using IntelliJ
, just add https
to Active profiles
textfield: open a browser and enter:
https://localhost:8443/index.html
To serve https + http2 you will need to install resources/localhost.crt
as a CA or just ignore the errors from the browser and run the app with -Dspring.profiles.active=https,http2
or if using IntelliJ
, just add https,http2
to Active profiles
textfield: open a browser and enter:
https://localhost:8443/index.html
In all cases you will need to open devtools and add Content-Encoding
to the table on network entry, I just have no time to create a test unit for it, sorry.
Comment From: userquin
It runs with Java 15 (OpenJDK)
and Spring Boot v2.4.0-RC1
.
Comment From: violetagg
This seems to be Reactor Netty issue - please create an issue here https://github.com/reactor/reactor-netty/issues
Comment From: userquin
@violetagg https://github.com/reactor/reactor-netty/pull/1381 also solves this issue (using 1.0.2-SNAPSHOT)