[jboss-remoting-commits] JBoss Remoting SVN: r5387 - remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/http.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Aug 26 15:37:42 EDT 2009


Author: ron.sigal at jboss.com
Date: 2009-08-26 15:37:42 -0400 (Wed, 26 Aug 2009)
New Revision: 5387

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/http/HTTPUnMarshaller.java
Log:
JBREM-1145: Made use of new content type test optional.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/http/HTTPUnMarshaller.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/http/HTTPUnMarshaller.java	2009-08-20 14:59:03 UTC (rev 5386)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/http/HTTPUnMarshaller.java	2009-08-26 19:37:42 UTC (rev 5387)
@@ -26,6 +26,7 @@
 import org.jboss.remoting.marshal.UnMarshaller;
 import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller;
 import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+import org.jboss.remoting.transport.web.WebUtil;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -228,11 +229,56 @@
 
    private boolean isBinaryData(Map metadata) throws IOException
    {
+      String useRemotingContentType = (String) metadata.get(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE);
+      if (Boolean.valueOf(useRemotingContentType).booleanValue())
+      {
+         return isBinaryDataNew(metadata);
+      }
+      else
+      {
+         return isBinaryDataOld(metadata);
+      }
+   }
+   
+   private boolean isBinaryDataOld(Map metadata) throws IOException
+   {
+      if (log.isTraceEnabled()) log.trace(this + " using isBinaryDataOld()");
       boolean isBinary = false;
 
       if(metadata != null)
       {
          // need to get the content type
+         Object value = metadata.get("Content-Type");
+         if(value == null)
+         {
+            value = metadata.get("content-type");
+         }
+         if(value != null)
+         {
+            if(value instanceof List)
+            {
+               List valueList = (List) value;
+               if(valueList != null && valueList.size() > 0)
+               {
+                  value = valueList.get(0);
+               }
+            }
+            isBinary = WebUtil.isBinary((String) value);
+         }
+      }
+      
+      if (log.isTraceEnabled()) log.trace(this + " isBinary: " + isBinary);
+      return isBinary;
+   }
+   
+   private boolean isBinaryDataNew(Map metadata) throws IOException
+   {
+      if (log.isTraceEnabled()) log.trace(this + " using isBinaryDataNew()");
+      boolean isBinary = true;
+      
+      if(metadata != null)
+      {
+         // need to get the content type
          String remotingContentType = null;
          Object o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE);
          if (o instanceof List)
@@ -245,11 +291,29 @@
          }
          else 
          {
-            log.warn(this + " unrecognized remotingContentType: " + o);
+            o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_LC);
+            if (o instanceof List)
+            {
+               remotingContentType = (String) ((List) o).get(0);
+            }
+            else if (o instanceof String)
+            {
+               remotingContentType = (String) o;
+            }
+            else if (o != null)
+            {
+               log.debug(this + " unrecognized remotingContentType: " + o);
+            }  
          }
-
-         isBinary = HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING.equals(remotingContentType);
+         
+         if (log.isTraceEnabled()) log.trace(this + " remotingContentType: " + remotingContentType);
+         if (remotingContentType != null)
+         {
+            isBinary = HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING.equals(remotingContentType);
+         }
       }
+      
+      if (log.isTraceEnabled()) log.trace(this + " isBinary: " + isBinary);
       return isBinary;
    }
 



More information about the jboss-remoting-commits mailing list