cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6528] Adding a property for users to disable sending CT with empty requests
Date Thu, 13 Aug 2015 12:07:46 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 6ba43377b -> 610791147


[CXF-6528] Adding a property for users to disable sending CT with empty requests


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

Branch: refs/heads/master
Commit: 61079114761b1a4a9898902ed07e5203bf5dd31c
Parents: 6ba4337
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu Aug 13 13:07:26 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu Aug 13 13:07:26 2015 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/transport/http/Headers.java     | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/61079114/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
index 3afb67a..3a4f7af 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Headers.java
@@ -67,7 +67,7 @@ public class Headers {
     public static final String HTTP_HEADERS_SETCOOKIE = "Set-Cookie";
     public static final String HTTP_HEADERS_LINK = "Link";
     public static final String EMPTY_REQUEST_PROPERTY = "org.apache.cxf.empty.request";
-    private static final String USE_ASYNC_PROPERTY = "use.async.http.conduit";
+    private static final String SET_EMPTY_REQUEST_CT_PROPERTY = "set.content.type.for.empty.request";
     private static final TimeZone TIME_ZONE_GMT = TimeZone.getTimeZone("GMT");
     private static final Logger LOG = LogUtils.getL7dLogger(Headers.class);
     
@@ -297,14 +297,21 @@ public class Headers {
      * @throws IOException
      */
     public void setProtocolHeadersInConnection(HttpURLConnection connection) throws IOException
{
+        // If no Content-Type is set for empty requests then HttpUrlConnection:
+        // - sets a form Content-Type for empty POST 
+        // - replaces custom Accept value with */* if HTTP proxy is used
+                
+        boolean dropContentType = false;
         boolean emptyRequest = PropertyUtils.isTrue(message.get(EMPTY_REQUEST_PROPERTY));
-        // HttpUrlConnection sets a form Content-Type and completely loses custom Accept

-        // if HTTP proxies are used if no Content-Type is set for empty requests 
-        boolean asyncConduitUsed = PropertyUtils.isTrue(message.get(USE_ASYNC_PROPERTY));
-        if (!asyncConduitUsed || !emptyRequest) {
+        if (emptyRequest) { 
+            // drop only if a user explicitly requested it by setting the property to false
+            dropContentType = !MessageUtils.getContextualBoolean(message, SET_EMPTY_REQUEST_CT_PROPERTY,
true);
+        }
+        if (!dropContentType) {
             String ct = emptyRequest ? "*/*" : determineContentType();
             connection.setRequestProperty(HttpHeaderHelper.CONTENT_TYPE, ct);
         }
+        
          
         transferProtocolHeadersToURLConnection(connection);
         logProtocolHeaders(Level.FINE);


Mime
View raw message