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:53:20 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes a1b0028a8 -> bf03cdc51


[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/1f36ca22
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/1f36ca22
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/1f36ca22

Branch: refs/heads/3.0.x-fixes
Commit: 1f36ca2212cea46a1a842b4770c7614fbb093c84
Parents: a1b0028
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:51:09 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/1f36ca22/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 737221b..44d9faf 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
@@ -1557,28 +1557,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