summaryrefslogtreecommitdiffhomepage
path: root/src/java/nginx/unit/IncludeResponseWrapper.java
blob: 4537114a2c9483f85defd22faa93695f82e4b586 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package nginx.unit;

import java.io.IOException;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

public class IncludeResponseWrapper extends HttpServletResponseWrapper {
    private static final Charset UTF_8 = StandardCharsets.UTF_8;

    public IncludeResponseWrapper(ServletResponse response)
    {
        super((HttpServletResponse) response);
    }

    @Override
    public void addCookie(Cookie cookie)
    {
        trace("addCookie: " + cookie.getName() + "=" + cookie.getValue());
    }

    @Override
    public void addDateHeader(String name, long date)
    {
        trace("addDateHeader: " + name + ": " + date);
    }

    @Override
    public void addHeader(String name, String value)
    {
        trace("addHeader: " + name + ": " + value);
    }

    @Override
    public void addIntHeader(String name, int value)
    {
        trace("addIntHeader: " + name + ": " + value);
    }

    @Override
    public void sendRedirect(String location) throws IOException
    {
        trace("sendRedirect: " + location);
    }

    @Override
    public void setDateHeader(String name, long date)
    {
        trace("setDateHeader: " + name + ": " + date);
    }

    @Override
    public void setHeader(String name, String value)
    {
        trace("setHeader: " + name + ": " + value);
    }

    @Override
    public void setIntHeader(String name, int value)
    {
        trace("setIntHeader: " + name + ": " + value);
    }

    @Override
    public void setStatus(int sc)
    {
        trace("setStatus: " + sc);
    }

    @Override
    @Deprecated
    public void setStatus(int sc, String sm)
    {
        trace("setStatus: " + sc + "; " + sm);
    }

    @Override
    public void reset()
    {
        trace("reset");
    }

    @Override
    public void setCharacterEncoding(String charset)
    {
        trace("setCharacterEncoding " + charset);
    }

    @Override
    public void setContentLength(int len)
    {
        trace("setContentLength: " + len);
    }

    @Override
    public void setContentLengthLong(long len)
    {
        trace("setContentLengthLong: " + len);
    }

    @Override
    public void setContentType(String type)
    {
        trace("setContentType: " + type);
    }

    private void trace(String msg)
    {
        msg = "IncludeResponse." + msg;
        Response.trace(0, msg.getBytes(UTF_8));
    }
}