-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fixes Vert.x issue 5371 #5372
Fixes Vert.x issue 5371 #5372
Conversation
vertx-core/src/main/java/io/vertx/core/http/impl/VertxCompressorHttp2ConnectionEncoder.java
Show resolved
Hide resolved
can you describe in your comment what is the result of the changes you did as outline in the original issue fixed ? Motivation: blah |
the content of the issue was great and very explanatory, it deserves to be used as comment following the pattern outline above |
@bjornhusberg tests don't see to pass, can you have a look ? |
@vietj Tests are updated |
Rerun? |
@bjornhusberg did that indeed, flaky test |
Motivation
The Http2 server-implementation handles content encoding differently compared to the Http1.x server-implementation, which leads to issues.
Http1.x:
The HttpContentCompressor determines the encoding based on the Accept-Encoding header right before writing the headers. If the request handler has already set a Content-Encoding header there will be no further encoding and if the Content-Encoding header is set to "identity" the header is removed by HttpChunkContentCompressor and the response is returned as-is.
Http2:
The encoding is determined already when setting up the stream in Http2ServerConnection and is then passed down to Http2ServerRequest and Http2ServerResponse where it is set using the Content-Encoding-header. The header content is later picked up by the CompressorHttp2ConnectionEncoder which compresses the response accordingly.
While the Http1.x-implementation works fine the Http2-implementation leads to two problems:
If the response is already encoded by the request handler and the Content-Encoding header has been set accordingly, the CompressorHttp2ConnectionEncoder picks up the encoding and encodes the response again, resulting in garbage returned to the client.
If the Content-Encoding is explicitly set to "identity", the response is not compressed by the CompressorHttp2ConnectionEncoder but the Content-Encoding holding "identity" leaks out to the client. This is unnecessary and leads to confusion for some clients.
Changes
Removes the setting of the Content-Encoding header in Http2ServerResponse.
Extended the CompressorHttp2ConnectionEncoder with a new VertxCompressorHttp2ConnectionEncoder.
Adds two new tests in Http2ServerTest that verifies the issues described in the GitHub issue.
Outcome
The two issues described are solved and tests are green. :)
#5371