java - Jetty 9 and GzipHandler -


i'm trying configure jetty 9 server serve data gzip compressed. unfortunatelly can't find description fits use case. think have use new gziphandler instead of gzipfilter (starting jetty 9.3 gzipfilter dummy).

my setup war file deployed on jetty 9 installation or run maven-jetty-plugin. no embedded jetty. have jetty-env.xml in /src/main/resources/meta-inf/resources/web-inf. there no other jetty related config files. appreciate setup doesn't need changes on jetty installation. should possible enable compression additional configuration in war file. compress static (files /src/main/resources/ , webjars) , dynamic (generated jersey) content.

i hope did such setup , can give me hint.

regards, johannes

the jetty distribution solution

if using jetty-distribution, go add gzip module configured ${jetty.base}

eg:

$ cd /path/to/mybase $ java -jar /path/to/jetty-dist/start.jar --add-to-start=gzip 

you have added gziphandler configuration of server.

look @ contents of /path/to/mybase/start.ini configuration options.

some background

since introduction of servlet 3.1 , new async i/o features brings, gzipfilter based approach no longer possible.

the implementation of gzip support in jetty based on container http output interceptor pattern. means gziphandler has defined @ point in jetty handler tree before webapp , webappcontext exists.

this means cannot add gziphandler via web-inf/web.xml or contained within war file, far far late in lifecycle of server add gziphandler.

it not possible add gziphandler safely embedded web-inf/jetty-web.xml, webappcontext thing can safely manipulate file.

handler tree example

you have 2 webapps being deployed: foo.war , baz.war

this server handler tree when not using gzip ...

server   +-- .gethandler()         +-- handlercollection (id="handlers")               +-- contexthandlercollection (id="contexts")               |     +-- webappcontext "/foo" (foo.war)               |     +-- webappcontext "/baz" (baz.war)               +-- defaulthandler 

this server handler tree when gziphandler in mix

server   +-- .gethandler()         +-- gziphandler               +-- handlercollection (id="handlers")                     +-- contexthandlercollection (id="contexts")                     |     +-- webappcontext "/foo" (foo.war)                     |     +-- webappcontext "/baz" (baz.war)                     +-- defaulthandler 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -