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-6548] Updating ClientProxyImpl to avoid setting CT if the body is null and transport Headers to let custom CT stay even if the request is empty if overriding CT */* is needed
Date Wed, 19 Aug 2015 11:02:36 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 01e718aea -> 7b9ed5feb


[CXF-6548] Updating ClientProxyImpl to avoid setting CT if the body is null and transport
Headers to let custom CT stay even if the request is empty if overriding CT */* is needed


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

Branch: refs/heads/3.0.x-fixes
Commit: 7b9ed5feb14eba8a0550819f3c6ef31b4136fd73
Parents: 01e718a
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed Aug 19 12:00:42 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Aug 19 12:02:03 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java   | 9 +++++----
 .../main/java/org/apache/cxf/transport/http/Headers.java    | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/7b9ed5fe/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
index e623676..92e5b67 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
@@ -204,10 +204,7 @@ public class ClientProxyImpl extends AbstractClient implements
             proxyImpl.setConfiguration(getConfiguration());
             return JAXRSClientFactory.createProxy(m.getReturnType(), proxyLoader, proxyImpl);
         } 
-        
         headers.putAll(paramHeaders);
-        setRequestHeaders(headers, ori, types.containsKey(ParameterType.FORM), 
-            bodyIndex == -1 || params[bodyIndex] == null ? null : params[bodyIndex].getClass(),
m.getReturnType());
         
         getState().setTemplates(getTemplateParametersMap(ori.getURITemplate(), pathParams));
         
@@ -223,6 +220,10 @@ public class ClientProxyImpl extends AbstractClient implements
             body = handleMultipart(types, ori, params);
         }
         
+        setRequestHeaders(headers, ori, types.containsKey(ParameterType.FORM), 
+            body == null ? null : body.getClass(), m.getReturnType());
+        
+        
         return doChainedInvocation(uri, headers, ori, body, bodyIndex, null, null);
         
     }
@@ -344,7 +345,7 @@ public class ClientProxyImpl extends AbstractClient implements
         if (headers.getFirst(HttpHeaders.CONTENT_TYPE) == null) {
             if (formParams || bodyClass != null && MultivaluedMap.class.isAssignableFrom(bodyClass))
{
                 headers.putSingle(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED);
-            } else {
+            } else if (bodyClass != null) {
                 String cType = ori.getConsumeTypes().isEmpty() 
                     || ori.getConsumeTypes().get(0).equals(MediaType.WILDCARD_TYPE) 
                     ? MediaType.APPLICATION_XML : JAXRSUtils.mediaTypeToString(ori.getConsumeTypes().get(0));
  

http://git-wip-us.apache.org/repos/asf/cxf/blob/7b9ed5fe/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 9b97021..7238fc1 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
@@ -309,7 +309,7 @@ public class Headers {
             dropContentType = !MessageUtils.getContextualBoolean(message, SET_EMPTY_REQUEST_CT_PROPERTY,
true);
         }
         if (!dropContentType) {
-            String ct = emptyRequest ? "*/*" : determineContentType();
+            String ct = emptyRequest && !headers.containsKey(Message.CONTENT_TYPE)
? "*/*" : determineContentType();
             connection.setRequestProperty(HttpHeaderHelper.CONTENT_TYPE, ct);
         }
         


Mime
View raw message