cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject cxf git commit: [CXF-7449]introduce a property to set an informative message for the reason phrase when it's null in the response message
Date Wed, 19 Jul 2017 07:25:27 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 8c7b7bb3a -> 79939ff18


[CXF-7449]introduce a property to set an informative message for the reason phrase when it's
null in the response message


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

Branch: refs/heads/master
Commit: 79939ff189c0872317594690be2d85ae05958fa8
Parents: 8c7b7bb
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Wed Jul 19 15:25:09 2017 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Wed Jul 19 15:25:09 2017 +0800

----------------------------------------------------------------------
 .../transport/http/URLConnectionHTTPConduit.java  | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/79939ff1/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
index 6941352..46f94f7 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
@@ -56,11 +56,15 @@ import org.apache.cxf.ws.addressing.EndpointReferenceType;
  */
 public class URLConnectionHTTPConduit extends HTTPConduit {
     public static final String HTTPURL_CONNECTION_METHOD_REFLECTION = "use.httpurlconnection.method.reflection";
+    public static final String SET_REASON_PHRASE_NOT_NULL = "set.reason.phrase.not.null";
 
     private static final boolean DEFAULT_USE_REFLECTION;
+    private static final boolean SET_REASON_PHRASE;
     static {
         DEFAULT_USE_REFLECTION =
             Boolean.valueOf(SystemPropertyAction.getProperty(HTTPURL_CONNECTION_METHOD_REFLECTION,
"false"));
+        SET_REASON_PHRASE = 
+            Boolean.valueOf(SystemPropertyAction.getProperty(SET_REASON_PHRASE_NOT_NULL,
"false"));
     }
 
     /**
@@ -383,7 +387,19 @@ public class URLConnectionHTTPConduit extends HTTPConduit {
             }
         }
         protected String getResponseMessage() throws IOException {
-            return connection.getResponseMessage();
+            Object o = this.outMessage.getContextualProperty(SET_REASON_PHRASE_NOT_NULL);
+            boolean b = SET_REASON_PHRASE;
+            if (o != null) {
+                b = MessageUtils.isTrue(o);
+            }
+            if (connection.getResponseMessage() == null && b) {
+                //some http server like tomcat 8.5+ won't return the
+                //reason phrase in response, return a informative value
+                //to tell user no reason phrase in the response instead of null
+                return "no reason phrase in the response";
+            } else {
+                return connection.getResponseMessage();
+            }
         }
         protected InputStream getPartialResponse() throws IOException {
             return ChunkedUtil.getPartialResponse(connection, connection.getResponseCode());


Mime
View raw message