GzipHandler Deprecations and User-Agent

+ Adding javadoc @deprecated for deprecated methods
+ Adding exclude support for user-agent
This commit is contained in:
Joakim Erdfelt 2015-12-08 18:40:48 -07:00
parent 5e3fbbccd0
commit bf104f71ab
1 changed files with 13 additions and 3 deletions

View File

@ -67,9 +67,6 @@ public class GzipHandler extends HandlerWrapper
{
private static final Logger LOG = Log.getLogger(GzipHandler.class);
// final protected Set<String> _mimeTypes=new HashSet<>();
// protected boolean _excludeMimeTypes=false;
// protected Set<String> _excludedUA;
protected int _bufferSize = 8192;
protected int _minGzipSize = 256;
protected String _vary = "Accept-Encoding, User-Agent";
@ -260,6 +257,7 @@ public class GzipHandler extends HandlerWrapper
* Get the mime types.
*
* @return mime types to set
* @deprecated use {@link #getExcludedMimeTypes()} or {@link #getIncludedMimeTypes()} instead
*/
@Deprecated
public Set<String> getMimeTypes()
@ -273,6 +271,7 @@ public class GzipHandler extends HandlerWrapper
*
* @param mimeTypes
* the mime types to set
* @deprecated use {@link #setExcludedMimeTypes()} or {@link #setIncludedMimeTypes()} instead
*/
@Deprecated
public void setMimeTypes(Set<String> mimeTypes)
@ -286,6 +285,7 @@ public class GzipHandler extends HandlerWrapper
*
* @param mimeTypes
* the mime types to set
* @deprecated use {@link #setExcludedMimeTypes()} or {@link #setIncludedMimeTypes()} instead
*/
@Deprecated
public void setMimeTypes(String mimeTypes)
@ -296,7 +296,9 @@ public class GzipHandler extends HandlerWrapper
/* ------------------------------------------------------------ */
/**
* Set the mime types.
* @deprecated use {@link #setExcludedMimeTypes()} instead
*/
@Deprecated
public void setExcludeMimeTypes(boolean exclude)
{
throw new UnsupportedOperationException("Use setExcludedMimeTypes instead");
@ -548,6 +550,14 @@ public class GzipHandler extends HandlerWrapper
}
}
// Exclude on User Agent
String ua = request.getHeader("User-Agent");
if(ua != null && !_agentPatterns.matches(ua))
{
LOG.debug("{} excluded by user-agent {}",this,request);
return false;
}
return true;
}