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:01:03 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 47cce42ce -> d3e2ebd99


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

Branch: refs/heads/master
Commit: d3e2ebd99778a9426b199fd7d2a1cc57a299af05
Parents: 47cce42
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:00:42 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/d3e2ebd9/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 c56db95..6edd18e 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);
         
     }
@@ -341,7 +342,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/d3e2ebd9/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 3a4f7af..6a81d23 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
@@ -308,7 +308,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