How is HTTP compression enabled on HTTP/1.1 connector?
teej May 11, 2005 1:33 PMUsing JBoss 4.0.1 with Tomcat 5.0.28, and the 'default' configuration.
Cannot get the HTTP connector to perform compression despite having the correct entries in Tomcat's server.xml.
As you'll see from my investigation below I've looked into the source-code and cannot find any clues. Googling hasn't helped so far either.
Any ideas?
TJ
<Service name="jboss.web" className="org.jboss.web.tomcat.tc5.StandardService"> <Connector port="80" address="84.x.y.z" compression="force" compressionMinSize="256" compressableMimeType="text/html,text/xml,text/plain" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true"/>
The connector being loaded is:
2005-05-11 17:18:25,639 INFO [org.apache.coyote.http11.Http11Protocol] Starting Coyote HTTP/1.1 on http-84.x.y.z-80
I'm testing for compresion using the port80 tool at http://www.port80software.com/tools/compresscheck which has just helped get IIS6 performing gzip compression in response to HTTP/1.1 "Accept-Encoding: gzip, deflate" request headers.
The connector documentation explicitly shows that compression is supported: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/catalina/docs/api/org/apache/coyote/http11/Http11Processor.html#setCompressableMimeTypes(java.lang.String)
Source code shows it too:
Http11Protocol.java
/** * Compression value. */ private String compression = "off"; private String noCompressionUserAgents = null; private String restrictedUserAgents = null; private String compressableMimeTypes = "text/html,text/xml,text/plain"; private int compressionMinSize = 2048; public void setCompression(String valueS) { compression = valueS; setAttribute("compression", valueS); }
Http11Processor.java
protected void prepareResponse() { if (useCompression) { outputBuffer.addActiveFilter(outputFilters[Constants.GZIP_FILTER]); // FIXME: Make content-encoding generation dynamic response.setHeader("Content-Encoding", "gzip"); // Make Proxies happy via Vary (from mod_deflate) response.setHeader("Vary", "Accept-Encoding"); }