From 2b83d9d9545a148eacca3fc5461eec27a502b1e2 Mon Sep 17 00:00:00 2001 From: Thomas Becker Date: Mon, 2 Apr 2012 13:41:36 +0200 Subject: [PATCH] 375692: cosmetic changes to get rid of warnings, etc. Change-Id: Id4d76a7f6e5bd989505e5233af73d5526b8e7c1f --- .../http/gzip/AbstractCompressedStream.java | 4 +-- .../eclipse/jetty/servlets/GzipFilter.java | 31 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/gzip/AbstractCompressedStream.java b/jetty-http/src/main/java/org/eclipse/jetty/http/gzip/AbstractCompressedStream.java index f879610be29..77ac1fe41d0 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/gzip/AbstractCompressedStream.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/gzip/AbstractCompressedStream.java @@ -13,8 +13,6 @@ package org.eclipse.jetty.http.gzip; -import java.io.Closeable; -import java.io.Flushable; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; @@ -32,7 +30,7 @@ import org.eclipse.jetty.util.ByteArrayOutputStream2; /** * Skeletal implementation of a CompressedStream. This class adds compression features to a ServletOutputStream and takes care of setting response headers, etc. * Major work and configuration is done here. Subclasses using different kinds of compression only have to implement the abstract methods doCompress() and - * setContentEncoding() using the desired compression and setting the appropiate Content-Encoding header string. + * setContentEncoding() using the desired compression and setting the appropriate Content-Encoding header string. */ public abstract class AbstractCompressedStream extends ServletOutputStream { diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java index 40564cae0e8..2f4128da184 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java @@ -150,21 +150,6 @@ public class GzipFilter extends UserAgentFilter { } - /* ------------------------------------------------------------ */ - public String selectCompression(String encodingHeader) - { - // TODO, this could be a little more robust. - // prefer gzip over deflate - if (encodingHeader!=null) - { - if (encodingHeader.toLowerCase().contains(GZIP)) - return GZIP; - if (encodingHeader.toLowerCase().contains(DEFLATE)) - return DEFLATE; - } - return null; - } - /* ------------------------------------------------------------ */ /** * @see org.eclipse.jetty.servlets.UserAgentFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) @@ -176,7 +161,6 @@ public class GzipFilter extends UserAgentFilter HttpServletRequest request=(HttpServletRequest)req; HttpServletResponse response=(HttpServletResponse)res; - String ae = request.getHeader("accept-encoding"); String compressionType = selectCompression(request.getHeader("accept-encoding")); if (compressionType!=null && !response.containsHeader("Content-Encoding") && !HttpMethods.HEAD.equalsIgnoreCase(request.getMethod())) { @@ -223,6 +207,21 @@ public class GzipFilter extends UserAgentFilter } } + /* ------------------------------------------------------------ */ + private String selectCompression(String encodingHeader) + { + // TODO, this could be a little more robust. + // prefer gzip over deflate + if (encodingHeader!=null) + { + if (encodingHeader.toLowerCase().contains(GZIP)) + return GZIP; + else if (encodingHeader.toLowerCase().contains(DEFLATE)) + return DEFLATE; + } + return null; + } + protected CompressedResponseWrapper createWrappedResponse(HttpServletRequest request, HttpServletResponse response, final String compressionType) { CompressedResponseWrapper wrappedResponse = null;