annotate src/org/eclipse/jetty/server/handler/GzipHandler.java @ 1067:56b515be91e1

fix use of HttpGenerator._reason
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 10 Nov 2016 00:08:39 -0700
parents 32d4b569567c
children
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.http.HttpMethods;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 import org.eclipse.jetty.http.gzip.CompressedResponseWrapper;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 import org.eclipse.jetty.http.gzip.AbstractCompressedStream;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 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
40 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
41 import org.slf4j.LoggerFactory;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 /* ------------------------------------------------------------ */
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 * 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
46 * <ul>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 * <li>The filter is mapped to a matching path</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 * <li>The response status code is >=200 and <300
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 * <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
50 * <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
51 * content-type is not "application/gzip"</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 * <li>No content-encoding is specified by the resource</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 * </ul>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 *
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 * <p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56 * 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
57 * 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
58 * </p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
59 */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
60 public class GzipHandler extends HandlerWrapper
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61 {
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
62 private static final Logger LOG = LoggerFactory.getLogger(GzipHandler.class);
802
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 protected Set<String> _mimeTypes;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
65 protected Set<String> _excluded;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
66 protected int _bufferSize = 8192;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
67 protected int _minGzipSize = 256;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
68 protected String _vary = "Accept-Encoding, User-Agent";
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
69
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
70 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
71 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
72 * Instantiates a new gzip handler.
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 public GzipHandler()
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 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
77
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
78 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
79 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
80 * Get the mime types.
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 * @return mime types to set
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 public Set<String> getMimeTypes()
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 return _mimeTypes;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
87 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
88
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
89 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
90 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
91 * Set the mime types.
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 * @param mimeTypes
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
94 * the mime types to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
95 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
96 public void setMimeTypes(Set<String> mimeTypes)
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 _mimeTypes = mimeTypes;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
99 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
100
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
101 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
102 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
103 * Set the mime types.
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 * @param mimeTypes
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
106 * the mime types to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
107 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
108 public void setMimeTypes(String mimeTypes)
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 if (mimeTypes != null)
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 _mimeTypes = new HashSet<String>();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
113 StringTokenizer tok = new StringTokenizer(mimeTypes,",",false);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
114 while (tok.hasMoreTokens())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
115 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
116 _mimeTypes.add(tok.nextToken());
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 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
119 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
120
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
121 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
122 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
123 * Get the excluded user agents.
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 * @return 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 public Set<String> getExcluded()
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 return _excluded;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
130 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
131
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
132 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
133 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
134 * Set the excluded user agents.
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 * @param excluded
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
137 * excluded user agents to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
138 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
139 public void setExcluded(Set<String> excluded)
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 _excluded = excluded;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
142 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
143
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
144 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
145 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
146 * Set the excluded user agents.
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 * @param excluded
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
149 * excluded user agents to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
150 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
151 public void setExcluded(String excluded)
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 if (excluded != null)
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 _excluded = new HashSet<String>();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
156 StringTokenizer tok = new StringTokenizer(excluded,",",false);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
157 while (tok.hasMoreTokens())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
158 _excluded.add(tok.nextToken());
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
159 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
160 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
161
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
162 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
163 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
164 * @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
165 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
166 public String getVary()
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 return _vary;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
169 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
170
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
171 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
172 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
173 * 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
174 * <p>
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
175 * 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
176 * 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
177 * 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
178 * 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
179 * User-Agent, unless the cache does some normalization of the UA string.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
180 * @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
181 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
182 public void setVary(String vary)
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 _vary = vary;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
185 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
186
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
187 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
188 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
189 * Get the buffer size.
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 * @return 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 public int getBufferSize()
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 return _bufferSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
196 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
197
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
198 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
199 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
200 * Set the buffer size.
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 * @param bufferSize
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
203 * buffer size to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
204 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
205 public void setBufferSize(int bufferSize)
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 _bufferSize = bufferSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
208 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
209
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
210 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
211 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
212 * Get the minimum reponse size.
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 * @return 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 public int getMinGzipSize()
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 return _minGzipSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
219 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
220
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
221 /* ------------------------------------------------------------ */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
222 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
223 * Set the minimum reponse size.
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 * @param minGzipSize
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
226 * minimum reponse size
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
227 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
228 public void setMinGzipSize(int minGzipSize)
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 _minGzipSize = minGzipSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
231 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
232
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
233 @Override
1000
32d4b569567c simplify handle()
Franklin Schmidt <fschmidt@gmail.com>
parents: 937
diff changeset
234 public void handle(String target, Request request, HttpServletResponse response) throws IOException, ServletException
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 if (_handler!=null && isStarted())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
237 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
238 String ae = request.getHeader("accept-encoding");
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
239 if (ae != null && ae.indexOf("gzip")>=0 && !response.containsHeader("Content-Encoding")
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
240 && !HttpMethods.HEAD.equalsIgnoreCase(request.getMethod()))
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 (_excluded!=null)
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 ua = request.getHeader("User-Agent");
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
245 if (_excluded.contains(ua))
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
246 {
1000
32d4b569567c simplify handle()
Franklin Schmidt <fschmidt@gmail.com>
parents: 937
diff changeset
247 _handler.handle(target, request, response);
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
248 return;
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 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
251
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
252 final CompressedResponseWrapper wrappedResponse = newGzipResponseWrapper(request,response);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
253
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
254 boolean exceptional=true;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
255 try
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
256 {
1000
32d4b569567c simplify handle()
Franklin Schmidt <fschmidt@gmail.com>
parents: 937
diff changeset
257 _handler.handle(target, request, wrappedResponse);
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
258 exceptional=false;
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 finally
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
261 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
262 if (exceptional && !response.isCommitted())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
263 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
264 wrappedResponse.resetBuffer();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
265 wrappedResponse.noCompression();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
266 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
267 else
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
268 wrappedResponse.finish();
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 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
271 else
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
272 {
1000
32d4b569567c simplify handle()
Franklin Schmidt <fschmidt@gmail.com>
parents: 937
diff changeset
273 _handler.handle(target, request, response);
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
274 }
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 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
277
916
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 * Allows derived implementations to replace ResponseWrapper implementation.
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 * @param request the request
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
282 * @param response the response
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
283 * @return the gzip response wrapper
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 protected CompressedResponseWrapper newGzipResponseWrapper(HttpServletRequest request, HttpServletResponse response)
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 return new CompressedResponseWrapper(request,response)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
288 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
289 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
290 super.setMimeTypes(GzipHandler.this._mimeTypes);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
291 super.setBufferSize(GzipHandler.this._bufferSize);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
292 super.setMinCompressSize(GzipHandler.this._minGzipSize);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
293 }
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 @Override
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
296 protected AbstractCompressedStream newCompressedStream(HttpServletRequest request,HttpServletResponse response) throws IOException
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
297 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
298 return new AbstractCompressedStream("gzip",request,this,_vary)
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 @Override
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
301 protected DeflaterOutputStream createStream() throws IOException
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
302 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
303 return new GZIPOutputStream(_response.getOutputStream(),_bufferSize);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
304 }
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 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
307
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
308 @Override
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
309 protected PrintWriter newWriter(OutputStream out,String encoding) throws UnsupportedEncodingException
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 return GzipHandler.this.newWriter(out,encoding);
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 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
315
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 * Allows derived implementations to replace PrintWriter implementation.
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 * @param out the out
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
320 * @param encoding the encoding
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
321 * @return the prints the writer
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
322 * @throws UnsupportedEncodingException
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
323 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
324 protected PrintWriter newWriter(OutputStream out,String encoding) throws UnsupportedEncodingException
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
325 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
326 return encoding==null?new PrintWriter(out):new PrintWriter(new OutputStreamWriter(out,encoding));
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
327 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
328 }