I'm working with Vertx 3.5.3 in a REST application that also provides static files using the Vertx Web StaticHandler handler.
I'm using own Vertx HttpServer with this configuration:
HttpServerOptions httpServerOptions = new HttpServerOptions()
.setCompressionSupported(true)
.setCompressionLevel(7)
.setTcpKeepAlive(true);
HttpServer httpServer = vertx.createHttpServer(httpServerOptions);
httpServer.requestStream().toObservable().subscribe(router::accept);
httpServer.listen(
serverConfig.getPort(),
serverConfig.getHost(),
result -> {
if (result.succeeded()) {
LOGGER.info("Server verticle is now up, listening on "
+ serverConfig.getHost() + ":" + serverConfig.getPort());
} else {
LOGGER.error("Error starting verticle on " + serverConfig.getHost() + ":" + serverConfig.getPort(), result.cause());
}
});
And this is the static handler configuration in the Vertx router:
// handler for static files
router.route("/*")
.handler(StaticHandler
.create()
.setAllowRootFileSystemAccess(false)
.setAlwaysAsyncFS(true)
.setCacheEntryTimeout(604800)
.setCachingEnabled(true)
.setDefaultContentEncoding("UTF-8")
.setDirectoryListing(false)
.setEnableFSTuning(true)
.setIncludeHidden(false)
.setIndexPage("index.html")
.setMaxAgeSeconds(604800)
.setSendVaryHeader(true));
That's the basic configuration.
My doubt is why when the compression (gzip) of the server is activated, it doesn't show the content-length
header in the browser, but sends the header Transfer-Encoding: chunked
. When I deactivate the compression (gzip) of the server, the server sends the content-length
header with the filesize.
An imagen of the first case (javascript file):
And an image of the second case (same javascript file):
There is a way to send from server the content-length
header when the compression (gzip) is active?
I found this PR in the Netty repo, so I assume Netty does allow this behavior and it's Vertx isn't sending the header.
Thanks.