wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r810125 - in /incubator/wink/trunk/wink-client/src: main/java/org/apache/wink/client/internal/handlers/ClientResponseImpl.java test/java/org/apache/wink/client/ClientTest.java
Date Tue, 01 Sep 2009 17:03:28 GMT
Author: bluk
Date: Tue Sep  1 17:03:28 2009
New Revision: 810125

URL: http://svn.apache.org/viewvc?rev=810125&view=rev
Log:
Should use octet-stream for content type when null

See [WINK-144]

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

Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/ClientResponseImpl.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/ClientResponseImpl.java?rev=810125&r1=810124&r2=810125&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/ClientResponseImpl.java
(original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/ClientResponseImpl.java
Tue Sep  1 17:03:28 2009
@@ -101,6 +101,9 @@
         RuntimeContextTLS.setRuntimeContext(runtimeContext);
         try {
             String contentType = getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
+            if (contentType == null || contentType.length() == 0) {
+                contentType = MediaType.APPLICATION_OCTET_STREAM;
+            }
             MediaType contentMediaType = MediaType.valueOf(contentType);
             MessageBodyReader<T> reader =
                 providersRegistry.getMessageBodyReader(type,

Modified: incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ClientTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ClientTest.java?rev=810125&r1=810124&r2=810125&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ClientTest.java
(original)
+++ incubator/wink/trunk/wink-client/src/test/java/org/apache/wink/client/ClientTest.java
Tue Sep  1 17:03:28 2009
@@ -265,4 +265,23 @@
             server.stopServer();
         }
     }
+
+    public void testResponseEmptyContentType() throws IOException {
+        MockHttpServer server = new MockHttpServer(34567);
+        server.setMockResponseCode(200);
+        server.setMockResponseContent("REQUEST".getBytes("UTF-8"));
+        server.setMockResponseContentType("");
+
+        server.startServer();
+        try {
+            RestClient client = getRestClient();
+            Resource resource =
+                client.resource(MessageFormat.format(SERVICE_URL, String.valueOf(server
+                    .getServerPort())));
+            String response = resource.accept(MediaType.TEXT_PLAIN_TYPE).get(String.class);
+            assertEquals("REQUEST", response);
+        } finally {
+            server.stopServer();
+        }
+    }
 }



Mime
View raw message