wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r816780 - in /incubator/wink/trunk/wink-client-apache-httpclient: pom.xml src/main/java/org/apache/wink/client/internal/handlers/ApacheHttpClientConnectionHandler.java
Date Fri, 18 Sep 2009 20:50:19 GMT
Author: bluk
Date: Fri Sep 18 20:50:18 2009
New Revision: 816780

URL: http://svn.apache.org/viewvc?rev=816780&view=rev
Log:
Use empty input stream for HTTPClient behavior

See [WINK-203]

Modified:
    incubator/wink/trunk/wink-client-apache-httpclient/pom.xml
    incubator/wink/trunk/wink-client-apache-httpclient/src/main/java/org/apache/wink/client/internal/handlers/ApacheHttpClientConnectionHandler.java

Modified: incubator/wink/trunk/wink-client-apache-httpclient/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client-apache-httpclient/pom.xml?rev=816780&r1=816779&r2=816780&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client-apache-httpclient/pom.xml (original)
+++ incubator/wink/trunk/wink-client-apache-httpclient/pom.xml Fri Sep 18 20:50:18 2009
@@ -43,7 +43,7 @@
         <dependency>
             <groupId>org.apache.httpcomponents</groupId>
             <artifactId>httpclient</artifactId>
-            <version>4.0-beta2</version>
+            <version>4.0</version>
         </dependency>
         <dependency>
             <groupId>org.apache.wink</groupId>

Modified: incubator/wink/trunk/wink-client-apache-httpclient/src/main/java/org/apache/wink/client/internal/handlers/ApacheHttpClientConnectionHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client-apache-httpclient/src/main/java/org/apache/wink/client/internal/handlers/ApacheHttpClientConnectionHandler.java?rev=816780&r1=816779&r2=816780&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client-apache-httpclient/src/main/java/org/apache/wink/client/internal/handlers/ApacheHttpClientConnectionHandler.java
(original)
+++ incubator/wink/trunk/wink-client-apache-httpclient/src/main/java/org/apache/wink/client/internal/handlers/ApacheHttpClientConnectionHandler.java
Fri Sep 18 20:50:18 2009
@@ -146,12 +146,29 @@
         return httpclient;
     }
 
+    /**
+     * An empty input stream to simulate an empty message body.
+     */
+    private static class EmptyInputStream extends InputStream {
+
+        @Override
+        public int read() throws IOException {
+            return -1;
+        }
+    }
+
     private ClientResponse processResponse(ClientRequest request,
                                            HandlerContext context,
                                            HttpResponse httpResponse) throws IllegalStateException,
         IOException {
         ClientResponse response = createResponse(request, httpResponse);
-        InputStream is = httpResponse.getEntity().getContent();
+        HttpEntity entity = httpResponse.getEntity();
+        InputStream is = null;
+        if (entity == null) {
+            is = new EmptyInputStream();
+        } else {
+            is = entity.getContent();
+        }
         is = adaptInputStream(is, response, context.getInputStreamAdapters());
         response.setEntity(is);
         return response;



Mime
View raw message