1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| package compressionFilters; |
18 |
| |
19 |
| import java.io.IOException; |
20 |
| import java.io.PrintWriter; |
21 |
| import java.util.Enumeration; |
22 |
| import javax.servlet.*; |
23 |
| import javax.servlet.http.*; |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| public class CompressionFilterTestServlet extends HttpServlet { |
32 |
| |
33 |
0
| public void doGet(HttpServletRequest request, HttpServletResponse response)
|
34 |
| throws ServletException, IOException { |
35 |
| |
36 |
0
| ServletOutputStream out = response.getOutputStream();
|
37 |
0
| response.setContentType("text/plain");
|
38 |
| |
39 |
0
| Enumeration e = ((HttpServletRequest)request).getHeaders("Accept-Encoding");
|
40 |
0
| while (e.hasMoreElements()) {
|
41 |
0
| String name = (String)e.nextElement();
|
42 |
0
| out.println(name);
|
43 |
0
| if (name.indexOf("gzip") != -1) {
|
44 |
0
| out.println("gzip supported -- able to compress");
|
45 |
| } |
46 |
| else { |
47 |
0
| out.println("gzip not supported");
|
48 |
| } |
49 |
| } |
50 |
| |
51 |
| |
52 |
0
| out.println("Compression Filter Test Servlet");
|
53 |
0
| out.close();
|
54 |
| } |
55 |
| |
56 |
| } |
57 |
| |