cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asold...@apache.org
Subject [1/2] cxf git commit: [CXF-6198] Adding property for getting SOAPFault for HTTP error code 400
Date Wed, 26 Aug 2015 09:56:41 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 8081b6dfe -> 2b15d7638


[CXF-6198] Adding property for getting SOAPFault for HTTP error code 400


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ca4e9565
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ca4e9565
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ca4e9565

Branch: refs/heads/2.7.x-fixes
Commit: ca4e9565c40dbe1e6c0c39e176b89cd158ccc607
Parents: 8081b6d
Author: Alessio Soldano <asoldano@redhat.com>
Authored: Wed Aug 26 09:38:46 2015 +0200
Committer: Alessio Soldano <asoldano@redhat.com>
Committed: Wed Aug 26 11:54:31 2015 +0200

----------------------------------------------------------------------
 .../apache/cxf/transport/http/HTTPConduit.java  | 35 +++++++++++++-------
 1 file changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ca4e9565/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
index 4c14abf..b16009e 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
@@ -1545,28 +1545,39 @@ public abstract class HTTPConduit
             return false;
         }
 
-        protected void handleResponseInternal() throws IOException {
+        protected int doProcessResponseCode() throws IOException {
             Exchange exchange = outMessage.getExchange();
-            int responseCode = getResponseCode();
-            if (responseCode == -1) {
+            int rc = getResponseCode();
+            if (rc == -1) {
                 LOG.warning("HTTP Response code appears to be corrupted");
             }
             if (exchange != null) {
-                exchange.put(Message.RESPONSE_CODE, responseCode);
+                exchange.put(Message.RESPONSE_CODE, rc);
             }
                        
-            // This property should be set in case the exceptions should not be handled here
-            // For example jax rs uses this
-            boolean noExceptions = MessageUtils.isTrue(outMessage.getContextualProperty(
-                "org.apache.cxf.transport.no_io_exceptions"));
+            // "org.apache.cxf.transport.no_io_exceptions" property should be set in case
the exceptions
+            // should not be handled here; for example jax rs uses this
             
-            if (responseCode >= 400 && responseCode != 500 && !noExceptions)
{
-                
-                if (responseCode == 404 || responseCode == 503) {
+            // "org.apache.cxf.transport.process_fault_on_http_400" property should be set
in case a
+            // soap fault because of a HTTP 400 should be returned back to the client (SOAP
1.2 spec)
+
+            if (rc >= 400 && rc != 500
+                && !MessageUtils.isTrue(outMessage.getContextualProperty("org.apache.cxf.transport.no_io_exceptions"))
+                && (rc > 400 || !MessageUtils.isTrue(outMessage
+                    .getContextualProperty("org.apache.cxf.transport.process_fault_on_http_400"))))
{
+
+                if (rc == 404 || rc == 503) {
                     exchange.put("org.apache.cxf.transport.service_not_available", true);
                 }
-                throw new HTTPException(responseCode, getResponseMessage(), url.toURL());
+
+                throw new HTTPException(rc, getResponseMessage(), url.toURL());
             }
+            return rc;
+        }
+        
+        protected void handleResponseInternal() throws IOException {
+            Exchange exchange = outMessage.getExchange();
+            int responseCode = doProcessResponseCode();
 
             InputStream in = null;
             // oneway or decoupled twoway calls may expect HTTP 202 with no content


Mime
View raw message