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-6648] CT should be dropped for GETs by default
Date Wed, 21 Oct 2015 11:47:19 GMT
Repository: cxf
Updated Branches:
  refs/heads/master aac1196c9 -> df6896ab2


[CXF-6648] CT should be dropped for GETs by default


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

Branch: refs/heads/master
Commit: df6896ab2ffe59238af8d7444524e6e24731dc2f
Parents: aac1196
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed Oct 21 12:47:03 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Oct 21 12:47:03 2015 +0100

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/df6896ab/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 6a81d23..65adab9 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
@@ -304,8 +304,16 @@ public class Headers {
         boolean dropContentType = false;
         boolean emptyRequest = PropertyUtils.isTrue(message.get(EMPTY_REQUEST_PROPERTY));
         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);
+            Object setCtForEmptyRequestProp = message.getContextualProperty(SET_EMPTY_REQUEST_CT_PROPERTY);
+            if (setCtForEmptyRequestProp != null) {
+                // If SET_EMPTY_REQUEST_CT_PROPERTY is set then do as a user prefers.
+                // CT will be dropped if setting CT for empty requests was explicitly disabled
+                dropContentType = PropertyUtils.isFalse(setCtForEmptyRequestProp);
+            } else if ("GET".equals((String)message.get(Message.HTTP_REQUEST_METHOD))) {
+                // otherwise if it is GET then just drop it
+                dropContentType = true;
+            }
+            
         }
         if (!dropContentType) {
             String ct = emptyRequest && !headers.containsKey(Message.CONTENT_TYPE)
? "*/*" : determineContentType();


Mime
View raw message