myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r729970 - in /myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago: ajax/api/AjaxResponseRenderer.java util/ResponseUtils.java
Date Mon, 29 Dec 2008 18:59:38 GMT
Author: bommel
Date: Mon Dec 29 10:59:37 2008
New Revision: 729970

URL: http://svn.apache.org/viewvc?rev=729970&view=rev
Log:
(TOBAGO-732) Websphere ignores charset if setContentType is called twice

Modified:
    myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
    myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java

Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java?rev=729970&r1=729969&r2=729970&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
Mon Dec 29 10:59:37 2008
@@ -186,18 +186,14 @@
   }
 
   private static void ensureContentTypeHeader(FacesContext facesContext, String charset,
String contentType) {
-    // TODO PortletRequest
-    if (facesContext.getExternalContext().getResponse() instanceof HttpServletResponse) {
-      HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
-
-      StringBuilder sb = new StringBuilder(contentType);
-      if (charset == null) {
-        charset = "UTF-8";
-      }
-      sb.append("; charset=");
-      sb.append(charset);
-      response.setContentType(sb.toString());
+    StringBuilder sb = new StringBuilder(contentType);
+    if (charset == null) {
+      charset = "UTF-8";
     }
+    sb.append("; charset=");
+    sb.append(charset);
+    ResponseUtils.ensureContentTypeHeader(facesContext, sb.toString());
+
   }
 
   private void writeResponse(FacesContext facesContext, RenderKit renderKit,

Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java?rev=729970&r1=729969&r2=729970&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java
(original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java
Mon Dec 29 10:59:37 2008
@@ -17,6 +17,9 @@
  * limitations under the License.
  */
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.servlet.http.HttpServletResponse;
@@ -27,6 +30,8 @@
  */
 public class ResponseUtils {
 
+  private static final Log LOG = LogFactory.getLog(ResponseUtils.class);
+
   @Deprecated
   public static void ensureNoCacheHeader(ExternalContext externalContext) {
     FacesContext facesContext = FacesContext.getCurrentInstance();
@@ -52,7 +57,13 @@
     // TODO PortletRequest
     if (facesContext.getExternalContext().getResponse() instanceof HttpServletResponse) {
       HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
-      response.setContentType(contentType);
+      if (!response.containsHeader("Content-Type")) {
+        response.setContentType(contentType);
+      } else {
+        if (LOG.isInfoEnabled()) {
+          LOG.info("Reponse already contains Header Content-Type. Ignore setting Content-Type
to " + contentType);
+        }
+      }
     }
   }
 }



Mime
View raw message