hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r446853 - in /jakarta/httpcomponents/httpclient/trunk/src: java/org/apache/httpclient/impl/DefaultResponseConsumedWatcher.java test/org/apache/httpclient/impl/TestDefaultResponseConsumedWatcher.java
Date Sat, 16 Sep 2006 11:12:45 GMT
Author: olegk
Date: Sat Sep 16 04:12:45 2006
New Revision: 446853

URL: http://svn.apache.org/viewvc?view=rev&rev=446853
Log:
Updated to the new HttpCore API

Modified:
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/httpclient/impl/DefaultResponseConsumedWatcher.java
    jakarta/httpcomponents/httpclient/trunk/src/test/org/apache/httpclient/impl/TestDefaultResponseConsumedWatcher.java

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/httpclient/impl/DefaultResponseConsumedWatcher.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/httpclient/impl/DefaultResponseConsumedWatcher.java?view=diff&rev=446853&r1=446852&r2=446853
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/httpclient/impl/DefaultResponseConsumedWatcher.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/httpclient/impl/DefaultResponseConsumedWatcher.java
Sat Sep 16 04:12:45 2006
@@ -35,6 +35,7 @@
 import org.apache.http.HttpConnection;
 import org.apache.http.HttpResponse;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.protocol.HttpContext;
 
 /**
  * <p>
@@ -50,9 +51,12 @@
 
     private final HttpConnection conn;
     private final HttpResponse response;
+    private final HttpContext context;
     
     public DefaultResponseConsumedWatcher(
-            final HttpConnection conn, final HttpResponse response) {
+            final HttpConnection conn, 
+            final HttpResponse response, 
+            final HttpContext context) {
         super();
         if (conn == null) {
             throw new IllegalArgumentException("HTTP connection may not be null");
@@ -62,11 +66,12 @@
         }
         this.conn = conn;
         this.response = response;
+        this.context = context;
     }
     
     public void responseConsumed() {
         ConnectionReuseStrategy s = new DefaultConnectionReuseStrategy();
-        if (!s.keepAlive(this.conn, this.response)) {
+        if (!s.keepAlive(this.response, this.context)) {
             try {
                 this.conn.close();
             } catch (IOException ex) {

Modified: jakarta/httpcomponents/httpclient/trunk/src/test/org/apache/httpclient/impl/TestDefaultResponseConsumedWatcher.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/test/org/apache/httpclient/impl/TestDefaultResponseConsumedWatcher.java?view=diff&rev=446853&r1=446852&r2=446853
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/test/org/apache/httpclient/impl/TestDefaultResponseConsumedWatcher.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/test/org/apache/httpclient/impl/TestDefaultResponseConsumedWatcher.java
Sat Sep 16 04:12:45 2006
@@ -38,6 +38,8 @@
 import org.apache.http.impl.DefaultHttpParams;
 import org.apache.http.message.BasicHttpResponse;
 import org.apache.http.mockup.HttpConnectionMockup;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpExecutionContext;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -63,14 +65,14 @@
 
     public void testIllegalResponseArg() throws Exception {
         try {
-            new DefaultResponseConsumedWatcher(null, null);
+            new DefaultResponseConsumedWatcher(null, null, null);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
             new DefaultResponseConsumedWatcher(
-                    new HttpConnectionMockup(), null);
+                    new HttpConnectionMockup(), null, null);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
@@ -78,6 +80,7 @@
     }
 
     public void testConnectionAutoClose() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
         byte[] data = new byte[] {'1', '2', '3'};
         HttpConnection conn = new HttpConnectionMockup();
         BasicHttpEntity entity = new BasicHttpEntity();
@@ -91,7 +94,8 @@
         response.setEntity(entity);
         
         // Wrap the entity input stream 
-        ResponseConsumedWatcher watcher = new DefaultResponseConsumedWatcher(conn, response);
+        ResponseConsumedWatcher watcher = new DefaultResponseConsumedWatcher(
+                conn, response, context);
         InputStream content = new AutoCloseInputStream(entity.getContent(), watcher);
         assertTrue(conn.isOpen());
         while (content.read() != -1) {}
@@ -99,6 +103,7 @@
     }
 
     public void testConnectionKeepAlive() throws Exception {
+        HttpContext context = new HttpExecutionContext(null);
         byte[] data = new byte[] {'1', '2', '3'};
         HttpConnection conn = new HttpConnectionMockup();
         BasicHttpEntity entity = new BasicHttpEntity();
@@ -112,7 +117,8 @@
         response.setEntity(entity);
         
         // Wrap the entity input stream 
-        ResponseConsumedWatcher watcher = new DefaultResponseConsumedWatcher(conn, response);
+        ResponseConsumedWatcher watcher = new DefaultResponseConsumedWatcher(
+                conn, response, context);
         InputStream content = new AutoCloseInputStream(entity.getContent(), watcher);
         
         assertTrue(conn.isOpen());



Mime
View raw message