annotate src/org/eclipse/jetty/server/handler/GzipHandler.java @ 931:6f7e2ff51879

remove ContinuationThrowable
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Oct 2016 19:24:55 -0600
parents 4de7f6e9c453
children aa7dc1802d29
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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: 802
diff changeset
42 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff 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: 820
diff 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: 820
diff changeset
66 protected Set<String> _mimeTypes;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
67 protected Set<String> _excluded;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
68 protected int _bufferSize = 8192;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
69 protected int _minGzipSize = 256;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
72 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
73 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
74 * Instantiates a new gzip handler.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
75 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
76 public GzipHandler()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
77 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
80 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
81 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
82 * Get the mime types.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
83 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
84 * @return mime types to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
85 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
86 public Set<String> getMimeTypes()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
87 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
88 return _mimeTypes;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
91 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
92 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
93 * Set the mime types.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
94 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
95 * @param mimeTypes
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
96 * the mime types to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
97 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
98 public void setMimeTypes(Set<String> mimeTypes)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
99 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
100 _mimeTypes = mimeTypes;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
103 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
104 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
105 * Set the mime types.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
106 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
107 * @param mimeTypes
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
108 * the mime types to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
109 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
110 public void setMimeTypes(String mimeTypes)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
111 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
112 if (mimeTypes != null)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
113 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
114 _mimeTypes = new HashSet<String>();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
115 StringTokenizer tok = new StringTokenizer(mimeTypes,",",false);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
116 while (tok.hasMoreTokens())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
117 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
118 _mimeTypes.add(tok.nextToken());
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
119 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
120 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
123 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
124 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
125 * Get the excluded user agents.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
126 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
127 * @return excluded user agents
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
128 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
129 public Set<String> getExcluded()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
130 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
131 return _excluded;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
134 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
135 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
136 * Set the excluded user agents.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
137 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
138 * @param excluded
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
139 * excluded user agents to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
140 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
141 public void setExcluded(Set<String> excluded)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
142 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
143 _excluded = excluded;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
146 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
147 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
148 * Set the excluded user agents.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
149 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
150 * @param excluded
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
151 * excluded user agents to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
152 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
153 public void setExcluded(String excluded)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
154 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
155 if (excluded != null)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
156 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
157 _excluded = new HashSet<String>();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
158 StringTokenizer tok = new StringTokenizer(excluded,",",false);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
159 while (tok.hasMoreTokens())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
160 _excluded.add(tok.nextToken());
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
161 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
164 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
165 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
167 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
168 public String getVary()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
169 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
170 return _vary;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
173 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
174 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
176 * <p>
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
178 * default from the excludedAgents. If user-agents are not to be excluded, then
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff 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: 820
diff changeset
181 * User-Agent, unless the cache does some normalization of the UA string.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
183 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
184 public void setVary(String vary)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
185 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
186 _vary = vary;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
189 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
190 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
191 * Get the buffer size.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
192 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
193 * @return the buffer size
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
194 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
195 public int getBufferSize()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
196 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
197 return _bufferSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
200 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
201 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
202 * Set the buffer size.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
203 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
204 * @param bufferSize
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
205 * buffer size to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
206 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
207 public void setBufferSize(int bufferSize)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
208 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
209 _bufferSize = bufferSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
212 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
213 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
214 * Get the minimum reponse size.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
215 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
216 * @return minimum reponse size
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
217 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
218 public int getMinGzipSize()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
219 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
220 return _minGzipSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
223 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
224 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
225 * Set the minimum reponse size.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
226 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
227 * @param minGzipSize
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
228 * minimum reponse size
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
229 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
230 public void setMinGzipSize(int minGzipSize)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
231 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
232 _minGzipSize = minGzipSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
235 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
236 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
238 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
239 @Override
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
241 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
242 if (_handler!=null && isStarted())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
243 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
244 String ae = request.getHeader("accept-encoding");
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
245 if (ae != null && ae.indexOf("gzip")>=0 && !response.containsHeader("Content-Encoding")
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
246 && !HttpMethods.HEAD.equalsIgnoreCase(request.getMethod()))
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
247 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
248 if (_excluded!=null)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
249 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
250 String ua = request.getHeader("User-Agent");
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
251 if (_excluded.contains(ua))
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
252 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
253 _handler.handle(target,baseRequest, request, response);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
254 return;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
255 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
258 final CompressedResponseWrapper wrappedResponse = newGzipResponseWrapper(request,response);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
259
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
260 boolean exceptional=true;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
261 try
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
262 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
263 _handler.handle(target, baseRequest, request, wrappedResponse);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
264 exceptional=false;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
265 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
266 finally
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
267 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
268 if (exceptional && !response.isCommitted())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
269 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
270 wrappedResponse.resetBuffer();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
271 wrappedResponse.noCompression();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
272 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
273 else
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
274 wrappedResponse.finish();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
275 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
276 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
277 else
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
278 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
279 _handler.handle(target,baseRequest, request, response);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
280 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
281 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff 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: 820
diff changeset
284 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
285 * Allows derived implementations to replace ResponseWrapper implementation.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
286 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
287 * @param request the request
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
288 * @param response the response
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
289 * @return the gzip response wrapper
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
290 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
291 protected CompressedResponseWrapper newGzipResponseWrapper(HttpServletRequest request, HttpServletResponse response)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
292 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
293 return new CompressedResponseWrapper(request,response)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
294 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
295 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
296 super.setMimeTypes(GzipHandler.this._mimeTypes);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
297 super.setBufferSize(GzipHandler.this._bufferSize);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
298 super.setMinCompressSize(GzipHandler.this._minGzipSize);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
299 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
300
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
301 @Override
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
302 protected AbstractCompressedStream newCompressedStream(HttpServletRequest request,HttpServletResponse response) throws IOException
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
303 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
304 return new AbstractCompressedStream("gzip",request,this,_vary)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
305 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
306 @Override
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
307 protected DeflaterOutputStream createStream() throws IOException
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
308 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
309 return new GZIPOutputStream(_response.getOutputStream(),_bufferSize);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
310 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
311 };
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
312 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
313
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
314 @Override
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
315 protected PrintWriter newWriter(OutputStream out,String encoding) throws UnsupportedEncodingException
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
316 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
317 return GzipHandler.this.newWriter(out,encoding);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
318 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
319 };
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
320 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
321
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
322 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
323 * Allows derived implementations to replace PrintWriter implementation.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
324 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
325 * @param out the out
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
326 * @param encoding the encoding
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
327 * @return the prints the writer
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
328 * @throws UnsupportedEncodingException
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
329 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
330 protected PrintWriter newWriter(OutputStream out,String encoding) throws UnsupportedEncodingException
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
331 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
332 return encoding==null?new PrintWriter(out):new PrintWriter(new OutputStreamWriter(out,encoding));
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
333 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
334 }