wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jra...@apache.org
Subject svn commit: r1030627 - /incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/AcceptHeaderHandler.java
Date Wed, 03 Nov 2010 19:27:22 GMT
Author: jramos
Date: Wed Nov  3 19:27:22 2010
New Revision: 1030627

URL: http://svn.apache.org/viewvc?rev=1030627&view=rev
Log:
Fix issue where json media types were being used by default for the accept header when the
user did not specify one and a ClientResponse is being returned by the RestClient

Modified:
    incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/AcceptHeaderHandler.java

Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/AcceptHeaderHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/AcceptHeaderHandler.java?rev=1030627&r1=1030626&r2=1030627&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/AcceptHeaderHandler.java
(original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/AcceptHeaderHandler.java
Wed Nov  3 19:27:22 2010
@@ -49,27 +49,30 @@ public class AcceptHeaderHandler impleme
                 request.getAttributes().get(ClientRequestImpl.RESPONSE_ENTITY_CLASS_TYPE);
             if (responseEntityClassType != null) {
                 Class<?> classType = (Class<?>)responseEntityClassType;
-                logger.trace("Response entity class is: {}", classType); //$NON-NLS-1$
-                Set<MediaType> mediaTypes =
-                    request.getAttribute(ProvidersRegistry.class)
-                        .getMessageBodyReaderMediaTypesLimitByIsReadable(classType,
-                                                                         RuntimeContextTLS
-                                                                             .getRuntimeContext());
-                logger.trace("Found media types: {}", mediaTypes); //$NON-NLS-1$
-                StringBuffer acceptHeader = new StringBuffer();
-                boolean isFirst = true;
-                for (MediaType mt : mediaTypes) {
-                    if (!isFirst) {
-                        acceptHeader.append(","); //$NON-NLS-1$
+                if (!classType.isAssignableFrom(ClientResponse.class)) {
+                    logger.trace("Response entity class is: {}", classType); //$NON-NLS-1$
+                    Set<MediaType> mediaTypes =
+                        request
+                            .getAttribute(ProvidersRegistry.class)
+                            .getMessageBodyReaderMediaTypesLimitByIsReadable(classType,
+                                                                             RuntimeContextTLS
+                                                                                 .getRuntimeContext());
+                    logger.trace("Found media types: {}", mediaTypes); //$NON-NLS-1$
+                    StringBuffer acceptHeader = new StringBuffer();
+                    boolean isFirst = true;
+                    for (MediaType mt : mediaTypes) {
+                        if (!isFirst) {
+                            acceptHeader.append(","); //$NON-NLS-1$
+                        }
+                        acceptHeader.append(mt.toString());
+                        isFirst = false;
+                    }
+                    if (acceptHeader.length() > 0) {
+                        String acceptValue = acceptHeader.toString();
+                        requestHeaders.add(HttpHeaders.ACCEPT, acceptValue);
+                        logger.info(Messages.getMessage("clientAcceptHeaderHandlerSetAccept",
//$NON-NLS-1$
+                                                        acceptValue));
                     }
-                    acceptHeader.append(mt.toString());
-                    isFirst = false;
-                }
-                if (acceptHeader.length() > 0) {
-                    String acceptValue = acceptHeader.toString();
-                    requestHeaders.add(HttpHeaders.ACCEPT, acceptValue);
-                    logger.info(Messages.getMessage("clientAcceptHeaderHandlerSetAccept",
//$NON-NLS-1$
-                                acceptValue));
                 }
             }
         }



Mime
View raw message