1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.internal.webapp;
21
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 import javax.servlet.http.HttpServletResponse;
26 import javax.servlet.http.HttpServletResponseWrapper;
27
28 public class DebugContentTypeResponse extends HttpServletResponseWrapper {
29 private static final Logger LOG = LoggerFactory.getLogger(DebugContentTypeResponse.class);
30
31 public DebugContentTypeResponse(HttpServletResponse response) {
32 super(response);
33 }
34
35 @Override
36 public void setContentType(String type) {
37 if (LOG.isDebugEnabled()) {
38 LOG.debug("Setting Content-Type to '" + type + "'.", new Exception());
39 }
40 super.setContentType(type);
41 }
42
43 @Override
44 public String getContentType() {
45 String type = super.getContentType();
46 if (LOG.isDebugEnabled()) {
47 LOG.debug("Getting Content-Type '" + type + "'.", new Exception());
48 }
49 return type;
50 }
51
52 @Override
53 public void setHeader(String name, String value) {
54 if ("Content-Type".equals(name)) {
55 if (LOG.isDebugEnabled()) {
56 LOG.debug("Setting Content-Type to '" + value + "'.", new Exception());
57 }
58 }
59 super.setHeader(name, value);
60 }
61
62 @Override
63 public void addHeader(String name, String value) {
64 if ("Content-Type".equals(name)) {
65 if (LOG.isDebugEnabled()) {
66 LOG.debug("Setting Content-Type to '" + value + "'.", new Exception());
67 }
68 }
69 super.addHeader(name, value);
70 }
71 }