annotate src/org/eclipse/jetty/server/handler/GzipHandler.java @ 935:aa7dc1802d29

remove ContinuationListener
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Oct 2016 21:15:24 -0600
parents 4de7f6e9c453
children 0541b6034003
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.http.HttpMethods;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 import org.eclipse.jetty.http.gzip.CompressedResponseWrapper;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 import org.eclipse.jetty.http.gzip.AbstractCompressedStream;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 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
41 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
42 import org.slf4j.LoggerFactory;
802
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 /**
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 * 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
47 * <ul>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 * <li>The filter is mapped to a matching path</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 * <li>The response status code is >=200 and <300
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 * <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
51 * <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
52 * content-type is not "application/gzip"</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 * <li>No content-encoding is specified by the resource</li>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 * </ul>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 *
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56 * <p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57 * 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
58 * 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
59 * </p>
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
60 */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61 public class GzipHandler extends HandlerWrapper
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
62 {
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
63 private static final Logger LOG = LoggerFactory.getLogger(GzipHandler.class);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
64
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
65 protected Set<String> _mimeTypes;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
66 protected Set<String> _excluded;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
67 protected int _bufferSize = 8192;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
68 protected int _minGzipSize = 256;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
69 protected String _vary = "Accept-Encoding, User-Agent";
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
70
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
73 * Instantiates a new gzip handler.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
74 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
75 public GzipHandler()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
76 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
77 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
78
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
81 * Get the mime types.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
82 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
83 * @return mime types to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
84 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
85 public Set<String> getMimeTypes()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
86 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
87 return _mimeTypes;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
88 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
89
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
92 * Set the mime types.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
93 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
94 * @param mimeTypes
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
95 * the mime types to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
96 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
97 public void setMimeTypes(Set<String> mimeTypes)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
98 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
99 _mimeTypes = mimeTypes;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
100 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
101
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
104 * Set the mime types.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
105 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
106 * @param mimeTypes
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
107 * the mime types to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
108 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
109 public void setMimeTypes(String mimeTypes)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
110 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
111 if (mimeTypes != null)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
112 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
113 _mimeTypes = new HashSet<String>();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
114 StringTokenizer tok = new StringTokenizer(mimeTypes,",",false);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
115 while (tok.hasMoreTokens())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
116 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
117 _mimeTypes.add(tok.nextToken());
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 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
120 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
121
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
124 * Get the excluded user agents.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
125 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
126 * @return excluded user agents
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
127 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
128 public Set<String> getExcluded()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
129 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
130 return _excluded;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
131 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
132
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
135 * Set the excluded user agents.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
136 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
137 * @param excluded
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
138 * excluded user agents to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
139 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
140 public void setExcluded(Set<String> excluded)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
141 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
142 _excluded = excluded;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
143 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
144
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
147 * Set the excluded user agents.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
148 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
149 * @param excluded
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
150 * excluded user agents to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
151 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
152 public void setExcluded(String excluded)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
153 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
154 if (excluded != null)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
155 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
156 _excluded = new HashSet<String>();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
157 StringTokenizer tok = new StringTokenizer(excluded,",",false);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
158 while (tok.hasMoreTokens())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
159 _excluded.add(tok.nextToken());
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
160 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
161 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
162
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
165 * @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
166 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
167 public String getVary()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
168 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
169 return _vary;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
170 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
171
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
174 * 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
175 * <p>
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
176 * 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
177 * 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
178 * 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
179 * 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
180 * User-Agent, unless the cache does some normalization of the UA string.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
181 * @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
182 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
183 public void setVary(String vary)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
184 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
185 _vary = vary;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
186 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
187
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
190 * Get the buffer size.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
191 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
192 * @return the buffer size
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
193 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
194 public int getBufferSize()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
195 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
196 return _bufferSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
197 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
198
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
201 * Set the buffer size.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
202 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
203 * @param bufferSize
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
204 * buffer size to set
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
205 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
206 public void setBufferSize(int bufferSize)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
207 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
208 _bufferSize = bufferSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
209 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
210
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
213 * Get the minimum reponse size.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
214 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
215 * @return minimum reponse size
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
216 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
217 public int getMinGzipSize()
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
218 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
219 return _minGzipSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
220 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
221
916
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 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
224 * Set the minimum reponse size.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
225 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
226 * @param minGzipSize
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
227 * minimum reponse size
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
228 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
229 public void setMinGzipSize(int minGzipSize)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
230 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
231 _minGzipSize = minGzipSize;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
232 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
233
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
234 /* ------------------------------------------------------------ */
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 * @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
237 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
238 @Override
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
239 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
240 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
241 if (_handler!=null && isStarted())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
242 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
243 String ae = request.getHeader("accept-encoding");
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
244 if (ae != null && ae.indexOf("gzip")>=0 && !response.containsHeader("Content-Encoding")
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
245 && !HttpMethods.HEAD.equalsIgnoreCase(request.getMethod()))
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
246 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
247 if (_excluded!=null)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
248 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
249 String ua = request.getHeader("User-Agent");
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
250 if (_excluded.contains(ua))
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
251 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
252 _handler.handle(target,baseRequest, request, response);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
253 return;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
254 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
255 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
256
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
257 final CompressedResponseWrapper wrappedResponse = newGzipResponseWrapper(request,response);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
258
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
259 boolean exceptional=true;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
260 try
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 _handler.handle(target, baseRequest, request, wrappedResponse);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
263 exceptional=false;
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
264 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
265 finally
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 if (exceptional && !response.isCommitted())
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
268 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
269 wrappedResponse.resetBuffer();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
270 wrappedResponse.noCompression();
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
271 }
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
272 else
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
273 wrappedResponse.finish();
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 else
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
277 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
278 _handler.handle(target,baseRequest, request, response);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
279 }
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 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
282
916
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
283 /**
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
284 * Allows derived implementations to replace ResponseWrapper implementation.
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
285 *
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
286 * @param request the request
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
287 * @param response the response
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
288 * @return the gzip response wrapper
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 protected CompressedResponseWrapper newGzipResponseWrapper(HttpServletRequest request, HttpServletResponse response)
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
291 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
292 return new CompressedResponseWrapper(request,response)
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 super.setMimeTypes(GzipHandler.this._mimeTypes);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
296 super.setBufferSize(GzipHandler.this._bufferSize);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
297 super.setMinCompressSize(GzipHandler.this._minGzipSize);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
298 }
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 AbstractCompressedStream newCompressedStream(HttpServletRequest request,HttpServletResponse response) 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 AbstractCompressedStream("gzip",request,this,_vary)
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 @Override
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
306 protected DeflaterOutputStream createStream() throws IOException
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 return new GZIPOutputStream(_response.getOutputStream(),_bufferSize);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
309 }
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 @Override
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
314 protected PrintWriter newWriter(OutputStream out,String encoding) throws UnsupportedEncodingException
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 return GzipHandler.this.newWriter(out,encoding);
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
317 }
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 * Allows derived implementations to replace PrintWriter implementation.
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 * @param out the out
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
325 * @param encoding the encoding
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
326 * @return the prints the writer
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
327 * @throws UnsupportedEncodingException
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
328 */
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
329 protected PrintWriter newWriter(OutputStream out,String encoding) throws UnsupportedEncodingException
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
330 {
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
331 return encoding==null?new PrintWriter(out):new PrintWriter(new OutputStreamWriter(out,encoding));
4de7f6e9c453 remove ContinuationSupport
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
332 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
333 }