Author: hiranya
Date: Thu Apr 29 09:01:21 2010
New Revision: 939236

URL: http://svn.apache.org/viewvc?rev=939236&view=rev
Log:
Fixing SYNAPSE-631.

Synapse RESTUtil class removes charset encoding from the content type header 
value before invoking the Axis2 RESTUtil class. But Axis2 RESTUtil expects the 
charset encoding to be in the content type string. Otherwise the default 
charset encoding will be used. Because of this for REST requests that has a 
charset encoding value different from the default, an error might occur while 
parsing the request payload. This caused some NHTTP tests to fail as well.

This commit removes the logic which removes the charset encoding info from the 
content type value.


Modified:
    
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/util/RESTUtil.java

Modified: 
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/util/RESTUtil.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/util/RESTUtil.java?rev=939236&r1=939235&r2=939236&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/util/RESTUtil.java
 (original)
+++ 
synapse/trunk/java/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/util/RESTUtil.java
 Thu Apr 29 09:01:21 2010
@@ -22,6 +22,7 @@ package org.apache.synapse.transport.nht
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisService;
@@ -35,7 +36,6 @@ import org.apache.http.Header;
 import org.apache.synapse.transport.nhttp.NHttpConfiguration;
 import org.apache.synapse.transport.nhttp.NhttpConstants;
 
-import javax.xml.namespace.QName;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
@@ -129,7 +129,7 @@ public class RESTUtil {
                                                   String requestURI, Header 
contentTypeHeader,
                                                   String httpMethod) throws 
AxisFault {
 
-        String contentType = getContentType(contentTypeHeader);
+        String contentType = contentTypeHeader != null ? 
contentTypeHeader.getValue() : null;
 
         prepareMessageContext(msgContext, requestURI, httpMethod, out, 
contentType);
 
@@ -179,33 +179,14 @@ public class RESTUtil {
                                           OutputStream os, String requestURI,
                                           Header contentTypeHeader) throws 
AxisFault {
 
-        String contentType = getContentType(contentTypeHeader);
-
-        prepareMessageContext(msgContext, requestURI, 
HTTPConstants.HTTP_METHOD_POST, os, contentType);
-
+        String contentType = contentTypeHeader != null ? 
contentTypeHeader.getValue() : null;
+        prepareMessageContext(msgContext, requestURI, 
HTTPConstants.HTTP_METHOD_POST,
+                os, contentType);
         
org.apache.axis2.transport.http.util.RESTUtil.processXMLRequest(msgContext, is, 
os,
                 contentType);
     }
 
     /**
-     * Given the contentType HTTP header it extracts the content-type of the 
request
-     *
-     * @param contentTypeHeader content type HTTP header
-     * @return content type value
-     */
-    private static String getContentType(Header contentTypeHeader) {
-
-        String contentTypeStr = contentTypeHeader != null ? 
contentTypeHeader.getValue() : null;
-        if (contentTypeStr != null) {
-            int index = contentTypeStr.indexOf(';');
-            if (index > 0) {
-                contentTypeStr = contentTypeStr.substring(0, index);
-            }
-        }
-        return contentTypeStr;
-    }
-
-    /**
      * prepare message context prior to call axis2 RestUtils
      *
      * @param msgContext  The MessageContext of the Request Message


Reply via email to