Mercurial Hosting > luan
annotate src/org/eclipse/jetty/server/handler/GzipHandler.java @ 925:720a98fb0253
remove scheduleDispatch()
| author | Franklin Schmidt <fschmidt@gmail.com> | 
|---|---|
| date | Sun, 09 Oct 2016 18:29:29 -0600 | 
| parents | 4de7f6e9c453 | 
| children | aa7dc1802d29 | 
| rev | line source | 
|---|---|
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 1 // | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 2 // ======================================================================== | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 4 // ------------------------------------------------------------------------ | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 5 // All rights reserved. This program and the accompanying materials | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 6 // are made available under the terms of the Eclipse Public License v1.0 | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 7 // and Apache License v2.0 which accompanies this distribution. | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 8 // | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 9 // The Eclipse Public License is available at | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 10 // http://www.eclipse.org/legal/epl-v10.html | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 11 // | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 12 // The Apache License v2.0 is available at | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 13 // http://www.opensource.org/licenses/apache2.0.php | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 14 // | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 15 // You may elect to redistribute this code under either of these licenses. | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 16 // ======================================================================== | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 17 // | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 18 | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 19 package org.eclipse.jetty.server.handler; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 20 | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 21 import java.io.IOException; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 22 import java.io.OutputStream; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 23 import java.io.OutputStreamWriter; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 24 import java.io.PrintWriter; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 25 import java.io.UnsupportedEncodingException; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 26 import java.util.HashSet; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 27 import java.util.Set; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 28 import java.util.StringTokenizer; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 29 import java.util.zip.DeflaterOutputStream; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 30 import java.util.zip.GZIPOutputStream; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 31 | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 32 import javax.servlet.ServletException; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 33 import javax.servlet.http.HttpServletRequest; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 34 import javax.servlet.http.HttpServletResponse; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 35 | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 36 import org.eclipse.jetty.continuation.Continuation; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 37 import org.eclipse.jetty.continuation.ContinuationListener; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 38 import org.eclipse.jetty.http.HttpMethods; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 39 import org.eclipse.jetty.http.gzip.CompressedResponseWrapper; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 40 import org.eclipse.jetty.http.gzip.AbstractCompressedStream; | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 41 import org.eclipse.jetty.server.Request; | 
| 820 
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
 Franklin Schmidt <fschmidt@gmail.com> parents: 
802diff
changeset | 42 import org.slf4j.Logger; | 
| 
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
 Franklin Schmidt <fschmidt@gmail.com> parents: 
802diff
changeset | 43 import org.slf4j.LoggerFactory; | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 44 | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 45 /* ------------------------------------------------------------ */ | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 46 /** | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 47 * GZIP Handler This handler will gzip the content of a response if: | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 48 * <ul> | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 49 * <li>The filter is mapped to a matching path</li> | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 50 * <li>The response status code is >=200 and <300 | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 51 * <li>The content length is unknown or more than the <code>minGzipSize</code> initParameter or the minGzipSize is 0(default)</li> | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 52 * <li>The content-type is in the comma separated list of mimeTypes set in the <code>mimeTypes</code> initParameter or if no mimeTypes are defined the | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 53 * content-type is not "application/gzip"</li> | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 54 * <li>No content-encoding is specified by the resource</li> | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 55 * </ul> | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 56 * | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 57 * <p> | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 58 * Compressing the content can greatly improve the network bandwidth usage, but at a cost of memory and CPU cycles. If this handler is used for static content, | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 59 * then use of efficient direct NIO may be prevented, thus use of the gzip mechanism of the <code>org.eclipse.jetty.servlet.DefaultServlet</code> is advised instead. | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 60 * </p> | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 61 */ | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 62 public class GzipHandler extends HandlerWrapper | 
| 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 63 { | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 64 private static final Logger LOG = LoggerFactory.getLogger(GzipHandler.class); | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 65 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 66 protected Set<String> _mimeTypes; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 67 protected Set<String> _excluded; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 68 protected int _bufferSize = 8192; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 69 protected int _minGzipSize = 256; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 70 protected String _vary = "Accept-Encoding, User-Agent"; | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 71 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 72 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 73 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 74 * Instantiates a new gzip handler. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 75 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 76 public GzipHandler() | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 77 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 78 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 79 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 80 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 81 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 82 * Get the mime types. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 83 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 84 * @return mime types to set | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 85 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 86 public Set<String> getMimeTypes() | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 87 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 88 return _mimeTypes; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 89 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 90 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 91 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 92 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 93 * Set the mime types. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 94 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 95 * @param mimeTypes | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 96 * the mime types to set | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 97 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 98 public void setMimeTypes(Set<String> mimeTypes) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 99 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 100 _mimeTypes = mimeTypes; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 101 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 102 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 103 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 104 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 105 * Set the mime types. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 106 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 107 * @param mimeTypes | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 108 * the mime types to set | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 109 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 110 public void setMimeTypes(String mimeTypes) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 111 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 112 if (mimeTypes != null) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 113 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 114 _mimeTypes = new HashSet<String>(); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 115 StringTokenizer tok = new StringTokenizer(mimeTypes,",",false); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 116 while (tok.hasMoreTokens()) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 117 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 118 _mimeTypes.add(tok.nextToken()); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 119 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 120 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 121 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 122 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 123 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 124 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 125 * Get the excluded user agents. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 126 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 127 * @return excluded user agents | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 128 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 129 public Set<String> getExcluded() | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 130 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 131 return _excluded; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 132 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 133 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 134 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 135 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 136 * Set the excluded user agents. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 137 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 138 * @param excluded | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 139 * excluded user agents to set | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 140 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 141 public void setExcluded(Set<String> excluded) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 142 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 143 _excluded = excluded; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 144 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 145 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 146 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 147 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 148 * Set the excluded user agents. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 149 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 150 * @param excluded | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 151 * excluded user agents to set | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 152 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 153 public void setExcluded(String excluded) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 154 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 155 if (excluded != null) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 156 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 157 _excluded = new HashSet<String>(); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 158 StringTokenizer tok = new StringTokenizer(excluded,",",false); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 159 while (tok.hasMoreTokens()) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 160 _excluded.add(tok.nextToken()); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 161 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 162 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 163 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 164 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 165 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 166 * @return The value of the Vary header set if a response can be compressed. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 167 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 168 public String getVary() | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 169 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 170 return _vary; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 171 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 172 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 173 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 174 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 175 * Set the value of the Vary header sent with responses that could be compressed. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 176 * <p> | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 177 * By default it is set to 'Accept-Encoding, User-Agent' since IE6 is excluded by | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 178 * default from the excludedAgents. If user-agents are not to be excluded, then | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 179 * this can be set to 'Accept-Encoding'. Note also that shared caches may cache | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 180 * many copies of a resource that is varied by User-Agent - one per variation of the | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 181 * User-Agent, unless the cache does some normalization of the UA string. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 182 * @param vary The value of the Vary header set if a response can be compressed. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 183 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 184 public void setVary(String vary) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 185 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 186 _vary = vary; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 187 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 188 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 189 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 190 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 191 * Get the buffer size. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 192 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 193 * @return the buffer size | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 194 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 195 public int getBufferSize() | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 196 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 197 return _bufferSize; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 198 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 199 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 200 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 201 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 202 * Set the buffer size. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 203 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 204 * @param bufferSize | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 205 * buffer size to set | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 206 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 207 public void setBufferSize(int bufferSize) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 208 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 209 _bufferSize = bufferSize; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 210 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 211 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 212 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 213 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 214 * Get the minimum reponse size. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 215 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 216 * @return minimum reponse size | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 217 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 218 public int getMinGzipSize() | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 219 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 220 return _minGzipSize; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 221 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 222 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 223 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 224 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 225 * Set the minimum reponse size. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 226 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 227 * @param minGzipSize | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 228 * minimum reponse size | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 229 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 230 public void setMinGzipSize(int minGzipSize) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 231 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 232 _minGzipSize = minGzipSize; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 233 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 234 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 235 /* ------------------------------------------------------------ */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 236 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 237 * @see org.eclipse.jetty.server.handler.HandlerWrapper#handle(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 238 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 239 @Override | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 240 public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 241 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 242 if (_handler!=null && isStarted()) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 243 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 244 String ae = request.getHeader("accept-encoding"); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 245 if (ae != null && ae.indexOf("gzip")>=0 && !response.containsHeader("Content-Encoding") | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 246 && !HttpMethods.HEAD.equalsIgnoreCase(request.getMethod())) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 247 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 248 if (_excluded!=null) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 249 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 250 String ua = request.getHeader("User-Agent"); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 251 if (_excluded.contains(ua)) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 252 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 253 _handler.handle(target,baseRequest, request, response); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 254 return; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 255 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 256 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 257 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 258 final CompressedResponseWrapper wrappedResponse = newGzipResponseWrapper(request,response); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 259 | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 260 boolean exceptional=true; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 261 try | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 262 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 263 _handler.handle(target, baseRequest, request, wrappedResponse); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 264 exceptional=false; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 265 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 266 finally | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 267 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 268 if (exceptional && !response.isCommitted()) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 269 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 270 wrappedResponse.resetBuffer(); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 271 wrappedResponse.noCompression(); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 272 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 273 else | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 274 wrappedResponse.finish(); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 275 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 276 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 277 else | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 278 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 279 _handler.handle(target,baseRequest, request, response); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 280 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 281 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 282 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 283 | 
| 916 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 284 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 285 * Allows derived implementations to replace ResponseWrapper implementation. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 286 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 287 * @param request the request | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 288 * @param response the response | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 289 * @return the gzip response wrapper | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 290 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 291 protected CompressedResponseWrapper newGzipResponseWrapper(HttpServletRequest request, HttpServletResponse response) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 292 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 293 return new CompressedResponseWrapper(request,response) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 294 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 295 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 296 super.setMimeTypes(GzipHandler.this._mimeTypes); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 297 super.setBufferSize(GzipHandler.this._bufferSize); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 298 super.setMinCompressSize(GzipHandler.this._minGzipSize); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 299 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 300 | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 301 @Override | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 302 protected AbstractCompressedStream newCompressedStream(HttpServletRequest request,HttpServletResponse response) throws IOException | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 303 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 304 return new AbstractCompressedStream("gzip",request,this,_vary) | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 305 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 306 @Override | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 307 protected DeflaterOutputStream createStream() throws IOException | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 308 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 309 return new GZIPOutputStream(_response.getOutputStream(),_bufferSize); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 310 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 311 }; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 312 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 313 | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 314 @Override | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 315 protected PrintWriter newWriter(OutputStream out,String encoding) throws UnsupportedEncodingException | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 316 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 317 return GzipHandler.this.newWriter(out,encoding); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 318 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 319 }; | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 320 } | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 321 | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 322 /** | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 323 * Allows derived implementations to replace PrintWriter implementation. | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 324 * | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 325 * @param out the out | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 326 * @param encoding the encoding | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 327 * @return the prints the writer | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 328 * @throws UnsupportedEncodingException | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 329 */ | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 330 protected PrintWriter newWriter(OutputStream out,String encoding) throws UnsupportedEncodingException | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 331 { | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 332 return encoding==null?new PrintWriter(out):new PrintWriter(new OutputStreamWriter(out,encoding)); | 
| 
4de7f6e9c453
remove ContinuationSupport
 Franklin Schmidt <fschmidt@gmail.com> parents: 
820diff
changeset | 333 } | 
| 802 
3428c60d7cfc
replace jetty jars with source
 Franklin Schmidt <fschmidt@gmail.com> parents: diff
changeset | 334 } | 
