incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r578015 - /incubator/sling/trunk/core/src/main/java/org/apache/sling/core/impl/ComponentResponseImpl.java
Date Fri, 21 Sep 2007 08:20:13 GMT
Author: fmeschbe
Date: Fri Sep 21 01:20:12 2007
New Revision: 578015

URL: http://svn.apache.org/viewvc?rev=578015&view=rev
Log:
Only include charset in content type if it has explicitly been set, otherwise omit it

Modified:
    incubator/sling/trunk/core/src/main/java/org/apache/sling/core/impl/ComponentResponseImpl.java

Modified: incubator/sling/trunk/core/src/main/java/org/apache/sling/core/impl/ComponentResponseImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/core/src/main/java/org/apache/sling/core/impl/ComponentResponseImpl.java?rev=578015&r1=578014&r2=578015&view=diff
==============================================================================
--- incubator/sling/trunk/core/src/main/java/org/apache/sling/core/impl/ComponentResponseImpl.java
(original)
+++ incubator/sling/trunk/core/src/main/java/org/apache/sling/core/impl/ComponentResponseImpl.java
Fri Sep 21 01:20:12 2007
@@ -36,7 +36,7 @@
 
     private final RequestData requestData;
     private String contentType = "text/html";
-    private String characterEncoding = "ISO-8859-1";
+    private String characterEncoding = null;
 
     protected ComponentResponseImpl(RequestData requestData) {
         super(requestData.getServletResponse());
@@ -45,39 +45,45 @@
 
     protected ComponentResponseImpl(ComponentResponseImpl response) {
         super(response);
-        this.requestData = response.getRequestData();
+        requestData = response.getRequestData();
     }
 
     protected final RequestData getRequestData() {
-        return this.requestData;
+        return requestData;
     }
 
     /**
      * @see javax.servlet.ServletResponseWrapper#flushBuffer()
      */
     public void flushBuffer() throws IOException {
-        this.getRequestData().getContentData().flushBuffer();
+        getRequestData().getContentData().flushBuffer();
     }
 
     /**
      * @see javax.servlet.ServletResponseWrapper#getBufferSize()
      */
     public int getBufferSize() {
-        return this.getRequestData().getContentData().getBufferSize();
+        return getRequestData().getContentData().getBufferSize();
     }
 
     /**
      * @see javax.servlet.ServletResponseWrapper#getCharacterEncoding()
      */
     public String getCharacterEncoding() {
-        return this.characterEncoding;
+        return characterEncoding;
     }
 
     /**
      * @see org.apache.sling.core.component.ComponentResponse#getContentType()
      */
     public String getContentType() {
-        return this.contentType + ";charset=" + this.characterEncoding;
+        // plaing content type if there is no character encoding
+        if (characterEncoding == null) {
+            return contentType;
+        }
+        
+        // otherwise append the charset
+        return contentType + ";charset=" + characterEncoding;
     }
 
     /**
@@ -85,7 +91,7 @@
      */
     public Locale getLocale() {
         // TODO Should use our Locale Resolver and not let the component set the locale,
right ??
-        return this.getResponse().getLocale();
+        return getResponse().getLocale();
     }
 
     /**
@@ -100,14 +106,14 @@
      * @see javax.servlet.ServletResponseWrapper#getOutputStream()
      */
     public ServletOutputStream getOutputStream() throws IOException {
-        return this.getRequestData().getBufferProvider().getOutputStream();
+        return getRequestData().getBufferProvider().getOutputStream();
     }
 
     /**
      * @see javax.servlet.ServletResponseWrapper#getWriter()
      */
     public PrintWriter getWriter() throws IOException {
-        return this.getRequestData().getBufferProvider().getWriter();
+        return getRequestData().getBufferProvider().getWriter();
     }
 
     /**
@@ -115,7 +121,7 @@
      */
     public boolean isCommitted() {
         // TODO: integrate with our output catcher
-        return this.getResponse().isCommitted();
+        return getResponse().isCommitted();
     }
 
     /**
@@ -123,28 +129,26 @@
      */
     public void reset() {
         // TODO: integrate with our output catcher
-        this.getResponse().reset();
+        getResponse().reset();
     }
 
     /**
      * @see javax.servlet.ServletResponseWrapper#resetBuffer()
      */
     public void resetBuffer() {
-        this.getRequestData().getContentData().resetBuffer();
+        getRequestData().getContentData().resetBuffer();
     }
 
     /**
      * @see javax.servlet.ServletResponseWrapper#setBufferSize(int)
      */
     public void setBufferSize(int size) {
-        this.getRequestData().getContentData().setBufferSize(size);
+        getRequestData().getContentData().setBufferSize(size);
     }
 
     public void setCharacterEncoding(String charset) {
-        if (charset != null && charset.length() > 0) {
-            // should actually check for charset validity ??
-            this.characterEncoding = charset;
-        }
+        // should actually check for charset validity ??
+        characterEncoding = charset;
     }
 
     /**
@@ -165,13 +169,15 @@
                 Map.Entry entry = (Map.Entry) parsedType.entrySet().iterator().next();
                 type = (String) entry.getKey();
                 String charset = (String) ((Map) entry.getValue()).get("charset");
-                this.setCharacterEncoding(charset);
+                if (charset != null && charset.length() > 0) {
+                    setCharacterEncoding(charset);
+                }
             }
         }
 
-        this.contentType = type;
+        contentType = type;
 
         // set the content type with charset on the underlying response
-        super.setContentType(this.getContentType());
+        super.setContentType(getContentType());
     }
 }



Mime
View raw message