cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-6021] Updating WbClient to default to a wildcard Accept
Date Tue, 23 Sep 2014 13:44:11 GMT
Repository: cxf
Updated Branches:
  refs/heads/master f767314cd -> 6fda6440b


[CXF-6021] Updating WbClient to default to a wildcard Accept


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

Branch: refs/heads/master
Commit: 6fda6440b8a38609e919b157b0ace36c8569c7a2
Parents: f767314
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Sep 23 14:43:55 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Sep 23 14:43:55 2014 +0100

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/client/WebClient.java   | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6fda6440/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
index 10fd904..f792025 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
@@ -982,19 +982,15 @@ public class WebClient extends AbstractClient {
     
     private MultivaluedMap<String, String> prepareHeaders(Class<?> responseClass,
Object body) {
         MultivaluedMap<String, String> headers = getHeaders();
-        boolean contentTypeNotSet = headers.getFirst(HttpHeaders.CONTENT_TYPE) == null;
-        if (contentTypeNotSet) {
-            String ct = "*/*";
-            if (body != null) { 
-                ct = body instanceof Form ? MediaType.APPLICATION_FORM_URLENCODED 
-                                          : MediaType.APPLICATION_XML;
-            }
-            headers.putSingle(HttpHeaders.CONTENT_TYPE, ct);
+        if (headers.getFirst(HttpHeaders.CONTENT_TYPE) == null && body != null) {
+            String contentType = body instanceof Form ? MediaType.APPLICATION_FORM_URLENCODED

+                                     : MediaType.APPLICATION_XML;
+            headers.putSingle(HttpHeaders.CONTENT_TYPE, contentType);
         }
         
         if (responseClass != null && responseClass != Response.class 
             && headers.getFirst(HttpHeaders.ACCEPT) == null) {
-            headers.putSingle(HttpHeaders.ACCEPT, JAXRSUtils.mediaTypeToString(MediaType.APPLICATION_XML_TYPE));
+            headers.putSingle(HttpHeaders.ACCEPT, MediaType.WILDCARD);
         }
         return headers;
     }


Mime
View raw message