Author: sagara
Date: Fri Dec 28 09:39:11 2012
New Revision: 1426443

URL: http://svn.apache.org/viewvc?rev=1426443&view=rev
Log:
Fix for AXIS2-5427. 

Modified:
    
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/RobustOutOnlyAxisOperation.java

Modified: 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/RobustOutOnlyAxisOperation.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/RobustOutOnlyAxisOperation.java?rev=1426443&r1=1426442&r2=1426443&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/RobustOutOnlyAxisOperation.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/RobustOutOnlyAxisOperation.java
 Fri Dec 28 09:39:11 2012
@@ -28,10 +28,12 @@ import org.apache.axis2.context.MessageC
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.util.Utils;
 
 import javax.xml.namespace.QName;
 import java.io.InputStream;
+import java.util.Map;
 
 public class RobustOutOnlyAxisOperation extends OutInAxisOperation {
 
@@ -77,7 +79,7 @@ public class RobustOutOnlyAxisOperation 
                 // set the variable
                 InputStream inStream = (InputStream) responseMessageContext.
                         getProperty(MessageContext.TRANSPORT_IN);
-                if (inStream != null) {
+                if (inStream != null && 
checkContentLength(responseMessageContext)) {
                     envelope = TransportUtils.createSOAPMessage(
                             responseMessageContext);
                     responseMessageContext.setEnvelope(envelope);
@@ -92,5 +94,36 @@ public class RobustOutOnlyAxisOperation 
                 }
             }
         }
-    }
+
+
+        private boolean checkContentLength(MessageContext 
responseMessageContext) {
+
+            Map<String, String> transportHeaders = (Map<String, String>) 
responseMessageContext
+                    .getProperty(MessageContext.TRANSPORT_HEADERS);
+
+            if (transportHeaders == null) {
+                // transportHeaders = null , we can't check this further and
+                // allow to try with message building.
+                return true;
+            }
+
+            String contentLengthStr = contentLengthStr = (String) 
transportHeaders
+                    .get(HTTPConstants.HEADER_CONTENT_LENGTH);
+
+            if (contentLengthStr == null) {
+                // contentLengthStr = null we can't check this further and 
allow
+                // to try with message building.
+                return true;
+            }
+
+            int contentLength = -1;
+            contentLength = Integer.parseInt(contentLengthStr);
+            if (contentLength > 0) {
+                // We have valid Content-Length no issue with message building.
+                return true;
+            }
+
+            return false;
+        }
+       }
 }


Reply via email to