xref: /unit/src/java/nginx/unit/IncludeResponseWrapper.java (revision 977:4f9268f27b57)
1 package nginx.unit;
2 
3 import java.io.IOException;
4 
5 import java.nio.charset.Charset;
6 import java.nio.charset.StandardCharsets;
7 
8 import javax.servlet.ServletResponse;
9 import javax.servlet.http.Cookie;
10 import javax.servlet.http.HttpServletResponse;
11 import javax.servlet.http.HttpServletResponseWrapper;
12 
13 public class IncludeResponseWrapper extends HttpServletResponseWrapper {
14     private static final Charset UTF_8 = StandardCharsets.UTF_8;
15 
IncludeResponseWrapper(ServletResponse response)16     public IncludeResponseWrapper(ServletResponse response)
17     {
18         super((HttpServletResponse) response);
19     }
20 
21     @Override
addCookie(Cookie cookie)22     public void addCookie(Cookie cookie)
23     {
24         trace("addCookie: " + cookie.getName() + "=" + cookie.getValue());
25     }
26 
27     @Override
addDateHeader(String name, long date)28     public void addDateHeader(String name, long date)
29     {
30         trace("addDateHeader: " + name + ": " + date);
31     }
32 
33     @Override
addHeader(String name, String value)34     public void addHeader(String name, String value)
35     {
36         trace("addHeader: " + name + ": " + value);
37     }
38 
39     @Override
addIntHeader(String name, int value)40     public void addIntHeader(String name, int value)
41     {
42         trace("addIntHeader: " + name + ": " + value);
43     }
44 
45     @Override
sendRedirect(String location)46     public void sendRedirect(String location) throws IOException
47     {
48         trace("sendRedirect: " + location);
49     }
50 
51     @Override
setDateHeader(String name, long date)52     public void setDateHeader(String name, long date)
53     {
54         trace("setDateHeader: " + name + ": " + date);
55     }
56 
57     @Override
setHeader(String name, String value)58     public void setHeader(String name, String value)
59     {
60         trace("setHeader: " + name + ": " + value);
61     }
62 
63     @Override
setIntHeader(String name, int value)64     public void setIntHeader(String name, int value)
65     {
66         trace("setIntHeader: " + name + ": " + value);
67     }
68 
69     @Override
setStatus(int sc)70     public void setStatus(int sc)
71     {
72         trace("setStatus: " + sc);
73     }
74 
75     @Override
76     @Deprecated
setStatus(int sc, String sm)77     public void setStatus(int sc, String sm)
78     {
79         trace("setStatus: " + sc + "; " + sm);
80     }
81 
82     @Override
reset()83     public void reset()
84     {
85         trace("reset");
86     }
87 
88     @Override
setCharacterEncoding(String charset)89     public void setCharacterEncoding(String charset)
90     {
91         trace("setCharacterEncoding " + charset);
92     }
93 
94     @Override
setContentLength(int len)95     public void setContentLength(int len)
96     {
97         trace("setContentLength: " + len);
98     }
99 
100     @Override
setContentLengthLong(long len)101     public void setContentLengthLong(long len)
102     {
103         trace("setContentLengthLong: " + len);
104     }
105 
106     @Override
setContentType(String type)107     public void setContentType(String type)
108     {
109         trace("setContentType: " + type);
110     }
111 
trace(String msg)112     private void trace(String msg)
113     {
114         msg = "IncludeResponse." + msg;
115         Response.trace(0, msg.getBytes(UTF_8));
116     }
117 }
118