hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1673256 - in /httpcomponents/httpcore/trunk: httpcore-ab/src/main/java/org/apache/http/benchmark/ httpcore-nio/src/examples/org/apache/http/examples/nio/ httpcore-nio/src/main/java/org/apache/http/nio/protocol/ httpcore-nio/src/test/java/o...
Date Mon, 13 Apr 2015 18:31:21 GMT
Author: olegk
Date: Mon Apr 13 18:31:20 2015
New Revision: 1673256

URL: http://svn.apache.org/r1673256
Log:
HTTPCORE-397: keep-alive strategy to take HTTP request as a parameter

Removed:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/NoConnectionReuseStrategy.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestNoConnectionReuseStrategy.java
Modified:
    httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncClientExchangeHandler.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/PipeliningClientExchangeHandler.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncClientExchangeHandler.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalPoolingHttpGet.java
    httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalReverseProxy.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ConnectionReuseStrategy.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java

Modified: httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
Mon Apr 13 18:31:20 2015
@@ -193,7 +193,7 @@ class BenchmarkWorker implements Runnabl
                     System.out.println();
                 }
 
-                if (!config.isKeepAlive() || !this.connstrategy.keepAlive(response, this.context))
{
+                if (!config.isKeepAlive() || !this.connstrategy.keepAlive(request, response,
this.context)) {
                     conn.close();
                 } else {
                     stats.incKeepAliveCount();

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
Mon Apr 13 18:31:20 2015
@@ -786,10 +786,10 @@ public class NHttpReverseProxy {
     static class ProxyIncomingConnectionReuseStrategy extends DefaultConnectionReuseStrategy
{
 
         @Override
-        public boolean keepAlive(final HttpResponse response, final HttpContext context)
{
+        public boolean keepAlive(final HttpRequest request, final HttpResponse response,
final HttpContext context) {
             NHttpConnection conn = (NHttpConnection) context.getAttribute(
                     HttpCoreContext.HTTP_CONNECTION);
-            boolean keepAlive = super.keepAlive(response, context);
+            boolean keepAlive = super.keepAlive(request, response, context);
             if (keepAlive) {
                 System.out.println("[client->proxy] connection kept alive " + conn);
             }
@@ -801,10 +801,10 @@ public class NHttpReverseProxy {
     static class ProxyOutgoingConnectionReuseStrategy extends DefaultConnectionReuseStrategy
{
 
         @Override
-        public boolean keepAlive(final HttpResponse response, final HttpContext context)
{
+        public boolean keepAlive(final HttpRequest request, final HttpResponse response,
final HttpContext context) {
             NHttpConnection conn = (NHttpConnection) context.getAttribute(
                     HttpCoreContext.HTTP_CONNECTION);
-            boolean keepAlive = super.keepAlive(response, context);
+            boolean keepAlive = super.keepAlive(request, response, context);
             if (keepAlive) {
                 System.out.println("[proxy->origin] connection kept alive " + conn);
             }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncClientExchangeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncClientExchangeHandler.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncClientExchangeHandler.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncClientExchangeHandler.java
Mon Apr 13 18:31:20 2015
@@ -173,7 +173,7 @@ public class BasicAsyncClientExchangeHan
         this.localContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
         this.httppocessor.process(response, this.localContext);
         this.responseConsumer.responseReceived(response);
-        this.keepAlive.set(this.connReuseStrategy.keepAlive(response, this.localContext));
+        this.keepAlive.set(this.connReuseStrategy.keepAlive(null, response, this.localContext));
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
Mon Apr 13 18:31:20 2015
@@ -678,6 +678,7 @@ public class HttpAsyncService implements
             final NHttpServerConnection conn,
             final State state) throws IOException, HttpException {
         final HttpContext context = outgoing.getContext();
+        final HttpRequest request = outgoing.getRequest();
         final HttpResponse response = outgoing.getResponse();
         final HttpAsyncResponseProducer responseProducer = outgoing.getProducer();
         try {
@@ -688,7 +689,7 @@ public class HttpAsyncService implements
         } finally {
             responseProducer.close();
         }
-        if (!this.connStrategy.keepAlive(response, context)) {
+        if (!this.connStrategy.keepAlive(request, response, context)) {
             conn.close();
         } else {
             // Ready to process new request

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/PipeliningClientExchangeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/PipeliningClientExchangeHandler.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/PipeliningClientExchangeHandler.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/PipeliningClientExchangeHandler.java
Mon Apr 13 18:31:20 2015
@@ -220,7 +220,7 @@ public class PipeliningClientExchangeHan
         this.httppocessor.process(response, this.localContext);
 
         responseConsumer.responseReceived(response);
-        this.keepAlive.set(this.connReuseStrategy.keepAlive(response, this.localContext));
+        this.keepAlive.set(this.connReuseStrategy.keepAlive(request, response, this.localContext));
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncClientExchangeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncClientExchangeHandler.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncClientExchangeHandler.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncClientExchangeHandler.java
Mon Apr 13 18:31:20 2015
@@ -330,9 +330,10 @@ public class TestBasicAsyncClientExchang
         final Object obj = new Object();
         Mockito.when(this.responseConsumer.getResult()).thenReturn(obj);
 
+        final BasicHttpRequest request = new BasicHttpRequest("GET", "/");
         final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200,
"OK");
 
-        Mockito.when(reuseStrategy.keepAlive(response, this.context)).thenReturn(Boolean.FALSE);
+        Mockito.when(reuseStrategy.keepAlive(request, response, this.context)).thenReturn(Boolean.FALSE);
 
         this.exchangeHandler.responseReceived(response);
         this.exchangeHandler.responseCompleted();

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
Mon Apr 13 18:31:20 2015
@@ -835,7 +835,7 @@ public class TestHttpAsyncService {
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
 
         Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
-        Mockito.when(this.reuseStrategy.keepAlive(response, exchangeContext)).thenReturn(Boolean.TRUE);
+        Mockito.when(this.reuseStrategy.keepAlive(request, response, exchangeContext)).thenReturn(Boolean.TRUE);
 
         this.protocolHandler.responseReady(this.conn);
 
@@ -875,7 +875,7 @@ public class TestHttpAsyncService {
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
 
         Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
-        Mockito.when(this.reuseStrategy.keepAlive(response, exchangeContext)).thenReturn(Boolean.TRUE);
+        Mockito.when(this.reuseStrategy.keepAlive(request, response, exchangeContext)).thenReturn(Boolean.TRUE);
 
         this.protocolHandler.responseReady(this.conn);
 
@@ -904,7 +904,7 @@ public class TestHttpAsyncService {
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
 
         Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
-        Mockito.when(this.reuseStrategy.keepAlive(response, exchangeContext)).thenReturn(Boolean.FALSE);
+        Mockito.when(this.reuseStrategy.keepAlive(request, response, exchangeContext)).thenReturn(Boolean.FALSE);
 
         this.protocolHandler.responseReady(this.conn);
 
@@ -965,7 +965,7 @@ public class TestHttpAsyncService {
 
         response.setEntity(new NStringEntity("stuff"));
         Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
-        Mockito.when(this.reuseStrategy.keepAlive(response, exchangeContext)).thenReturn(Boolean.TRUE);
+        Mockito.when(this.reuseStrategy.keepAlive(request, response, exchangeContext)).thenReturn(Boolean.TRUE);
 
         this.protocolHandler.responseReady(this.conn);
 
@@ -997,7 +997,7 @@ public class TestHttpAsyncService {
 
         response.setEntity(new NStringEntity("stuff"));
         Mockito.when(this.responseProducer.generateResponse()).thenReturn(response);
-        Mockito.when(this.reuseStrategy.keepAlive(response, exchangeContext)).thenReturn(Boolean.TRUE);
+        Mockito.when(this.reuseStrategy.keepAlive(request, response, exchangeContext)).thenReturn(Boolean.TRUE);
 
         this.protocolHandler.responseReady(this.conn);
 
@@ -1293,7 +1293,7 @@ public class TestHttpAsyncService {
         state.setOutgoing(outgoing);
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
         Mockito.when(this.encoder.isCompleted()).thenReturn(true);
-        Mockito.when(this.reuseStrategy.keepAlive(response, exchangeContext)).thenReturn(Boolean.TRUE);
+        Mockito.when(this.reuseStrategy.keepAlive(request, response, exchangeContext)).thenReturn(Boolean.TRUE);
 
         this.protocolHandler.outputReady(conn, this.encoder);
 
@@ -1319,7 +1319,7 @@ public class TestHttpAsyncService {
         state.setOutgoing(outgoing);
         this.connContext.setAttribute(HttpAsyncService.HTTP_EXCHANGE_STATE, state);
         Mockito.when(this.encoder.isCompleted()).thenReturn(true);
-        Mockito.when(this.reuseStrategy.keepAlive(response, exchangeContext)).thenReturn(Boolean.FALSE);
+        Mockito.when(this.reuseStrategy.keepAlive(request, response, exchangeContext)).thenReturn(Boolean.FALSE);
 
         this.protocolHandler.outputReady(conn, this.encoder);
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java
Mon Apr 13 18:31:20 2015
@@ -90,7 +90,7 @@ public class ElementalHttpGet {
                 System.out.println("<< Response: " + response.getStatusLine());
                 System.out.println(EntityUtils.toString(response.getEntity()));
                 System.out.println("==============");
-                if (!connStrategy.keepAlive(response, coreContext)) {
+                if (!connStrategy.keepAlive(request, response, coreContext)) {
                     conn.close();
                 } else {
                     System.out.println("Connection kept alive...");

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
Mon Apr 13 18:31:20 2015
@@ -109,7 +109,7 @@ public class ElementalHttpPost {
                 System.out.println("<< Response: " + response.getStatusLine());
                 System.out.println(EntityUtils.toString(response.getEntity()));
                 System.out.println("==============");
-                if (!connStrategy.keepAlive(response, coreContext)) {
+                if (!connStrategy.keepAlive(request, response, coreContext)) {
                     conn.close();
                 } else {
                     System.out.println("Connection kept alive...");

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalPoolingHttpGet.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalPoolingHttpGet.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalPoolingHttpGet.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalPoolingHttpGet.java
Mon Apr 13 18:31:20 2015
@@ -109,7 +109,7 @@ public class ElementalPoolingHttpGet {
                         System.out.println("<< Response: " + response.getStatusLine());
                         System.out.println(EntityUtils.toString(response.getEntity()));
 
-                        reusable = connStrategy.keepAlive(response, coreContext);
+                        reusable = connStrategy.keepAlive(request, response, coreContext);
                     } catch (IOException | HttpException ex) {
                         throw ex;
                     } finally {

Modified: httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalReverseProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalReverseProxy.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalReverseProxy.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/examples/org/apache/http/examples/ElementalReverseProxy.java
Mon Apr 13 18:31:20 2015
@@ -152,7 +152,7 @@ public class ElementalReverseProxy {
 
             System.out.println("<< Response: " + response.getStatusLine());
 
-            final boolean keepalive = this.connStrategy.keepAlive(response, context);
+            final boolean keepalive = this.connStrategy.keepAlive(request, response, context);
             context.setAttribute(HTTP_CONN_KEEPALIVE, new Boolean(keepalive));
         }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ConnectionReuseStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ConnectionReuseStrategy.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ConnectionReuseStrategy.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/ConnectionReuseStrategy.java
Mon Apr 13 18:31:20 2015
@@ -59,14 +59,16 @@ public interface ConnectionReuseStrategy
      * connection reuse strategy.
      * </p>
      *
+     * @param request
+     *          The last request transmitted over that connection.
      * @param response
-     *          The last response received over that connection.
+     *          The last response transmitted over that connection.
      * @param context   the context in which the connection is being
      *          used.
      *
      * @return {@code true} if the connection is allowed to be reused, or
      *         {@code false} if it MUST NOT be reused
      */
-    boolean keepAlive(HttpResponse response, HttpContext context);
+    boolean keepAlive(HttpRequest request, HttpResponse response, HttpContext context);
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java
Mon Apr 13 18:31:20 2015
@@ -33,6 +33,7 @@ import org.apache.http.ConnectionReuseSt
 import org.apache.http.Header;
 import org.apache.http.HeaderElements;
 import org.apache.http.HttpHeaders;
+import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
@@ -69,14 +70,9 @@ public class DefaultConnectionReuseStrat
         super();
     }
 
-    @Override
-    public int hashCode() {
-        return super.hashCode();
-    }
-
     // see interface ConnectionReuseStrategy
     @Override
-    public boolean keepAlive(final HttpResponse response,
+    public boolean keepAlive(final HttpRequest request, final HttpResponse response,
                              final HttpContext context) {
         Args.notNull(response, "HTTP response");
         Args.notNull(context, "HTTP context");

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/protocol/HttpService.java
Mon Apr 13 18:31:20 2015
@@ -218,7 +218,7 @@ public class HttpService {
         }
         conn.flush();
 
-        if (!this.connStrategy.keepAlive(response, context)) {
+        if (!this.connStrategy.keepAlive(request, response, context)) {
             conn.close();
         }
     }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
Mon Apr 13 18:31:20 2015
@@ -54,39 +54,39 @@ public class TestDefaultConnectionReuseS
 
     @Test(expected=IllegalArgumentException.class)
     public void testIllegalResponseArg() throws Exception {
-        reuseStrategy.keepAlive(null, this.context);
+        reuseStrategy.keepAlive(null, null, this.context);
     }
 
     @Test(expected=IllegalArgumentException.class)
     public void testIllegalContextArg() throws Exception {
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        reuseStrategy.keepAlive(response, null);
+        reuseStrategy.keepAlive(null, response, null);
     }
 
     @Test
     public void testNoContentLengthResponseHttp1_0() throws Exception {
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
     public void testNoContentLengthResponseHttp1_1() throws Exception {
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
     public void testChunkedContent() throws Exception {
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         response.addHeader("Transfer-Encoding", "chunked");
-        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
     public void testIgnoreInvalidKeepAlive() throws Exception {
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
         response.addHeader("Connection", "keep-alive");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -95,7 +95,7 @@ public class TestDefaultConnectionReuseS
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "close");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -105,28 +105,28 @@ public class TestDefaultConnectionReuseS
         response.addHeader("Content-Length", "10");
         response.addHeader("Connection", "keep-alive");
 
-        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
     public void testHTTP10Default() throws Exception {
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
         response.addHeader("Content-Length", "10");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
     public void testHTTP11Default() throws Exception {
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         response.addHeader("Content-Length", "10");
-        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
     public void testFutureHTTP() throws Exception {
         final HttpResponse response = new BasicHttpResponse(new HttpVersion(3, 45), 200,
"OK");
         response.addHeader("Content-Length", "10");
-        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -135,7 +135,7 @@ public class TestDefaultConnectionReuseS
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
         response.addHeader("Content-Length", "10");
         response.addHeader("Connection", "keep--alive");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -144,7 +144,7 @@ public class TestDefaultConnectionReuseS
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
         response.addHeader("Content-Length", "10");
         response.addHeader("Connection", null);
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -153,7 +153,7 @@ public class TestDefaultConnectionReuseS
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "yadda, cLOSe, dumdy");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -162,7 +162,7 @@ public class TestDefaultConnectionReuseS
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "yadda, kEEP-alive, dumdy");
-        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -171,7 +171,7 @@ public class TestDefaultConnectionReuseS
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         response.addHeader("Transfer-Encoding", "chunked");
         response.addHeader("Connection", "yadda, keep-alive, close, dumdy");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -182,7 +182,7 @@ public class TestDefaultConnectionReuseS
         response.addHeader("Connection", "yadda, close, dumdy");
         response.addHeader("Proxy-Connection", "keep-alive");
         // Connection takes precedence over Proxy-Connection
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -195,7 +195,7 @@ public class TestDefaultConnectionReuseS
         // Connection takes precedence over Proxy-Connection,
         // even if it doesn't contain a recognized token.
         // Default for HTTP/1.1 is to keep alive.
-        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -207,7 +207,7 @@ public class TestDefaultConnectionReuseS
         response.addHeader("Proxy-Connection", "close");
         // Connection takes precedence over Proxy-Connection,
         // even if it is empty. Default for HTTP/1.1 is to keep alive.
-        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -216,7 +216,7 @@ public class TestDefaultConnectionReuseS
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         response.addHeader("Content-Length", "10");
         response.addHeader("Content-Length", "11");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -224,7 +224,7 @@ public class TestDefaultConnectionReuseS
         // Use HTTP 1.1
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         response.addHeader("Content-Length", "crap");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -232,7 +232,7 @@ public class TestDefaultConnectionReuseS
         // Use HTTP 1.1
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         response.addHeader("Content-Length", "-10");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -240,7 +240,7 @@ public class TestDefaultConnectionReuseS
         // Use HTTP 1.1
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
                 HttpStatus.SC_NO_CONTENT, "No Content");
-        Assert.assertTrue(reuseStrategy.keepAlive(response, context));
+        Assert.assertTrue(reuseStrategy.keepAlive(null, response, context));
     }
 
     @Test
@@ -248,7 +248,7 @@ public class TestDefaultConnectionReuseS
         // Use HTTP 1.0
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0,
                 HttpStatus.SC_NO_CONTENT, "No Content");
-        Assert.assertFalse(reuseStrategy.keepAlive(response, context));
+        Assert.assertFalse(reuseStrategy.keepAlive(null, response, context));
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
Mon Apr 13 18:31:20 2015
@@ -155,7 +155,7 @@ public class TestSyncHttp {
                 for (int i = 0; i < expected.length; i++) {
                     Assert.assertEquals(expected[i], received[i]);
                 }
-                if (!this.client.keepAlive(response)) {
+                if (!this.client.keepAlive(get, response)) {
                     conn.close();
                 }
             }
@@ -236,7 +236,7 @@ public class TestSyncHttp {
                 for (int i = 0; i < expected.length; i++) {
                     Assert.assertEquals(expected[i], received[i]);
                 }
-                if (!this.client.keepAlive(response)) {
+                if (!this.client.keepAlive(post, response)) {
                     conn.close();
                 }
             }
@@ -316,7 +316,7 @@ public class TestSyncHttp {
                 for (int i = 0; i < expected.length; i++) {
                     Assert.assertEquals(expected[i], received[i]);
                 }
-                if (!this.client.keepAlive(response)) {
+                if (!this.client.keepAlive(post, response)) {
                     conn.close();
                 }
             }
@@ -397,7 +397,7 @@ public class TestSyncHttp {
                 for (int i = 0; i < expected.length; i++) {
                     Assert.assertEquals(expected[i], received[i]);
                 }
-                if (!this.client.keepAlive(response)) {
+                if (!this.client.keepAlive(post, response)) {
                     conn.close();
                 }
             }
@@ -479,7 +479,7 @@ public class TestSyncHttp {
                 for (int i = 0; i < expected.length; i++) {
                     Assert.assertEquals(expected[i], received[i]);
                 }
-                if (!this.client.keepAlive(response)) {
+                if (!this.client.keepAlive(post, response)) {
                     conn.close();
                 }
             }
@@ -572,7 +572,7 @@ public class TestSyncHttp {
                     Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
                 }
 
-                if (!this.client.keepAlive(response)) {
+                if (!this.client.keepAlive(post, response)) {
                     conn.close();
                 }
             }
@@ -734,7 +734,7 @@ public class TestSyncHttp {
                         count++;
                     }
                     Assert.assertEquals(n, count);
-                    if (!this.client.keepAlive(response)) {
+                    if (!this.client.keepAlive(post, response)) {
                         conn.close();
                     }
                 }
@@ -926,7 +926,7 @@ public class TestSyncHttp {
                 final BasicHttpRequest get = new BasicHttpRequest("GET", "/?" + r);
                 final HttpResponse response = this.client.execute(get, host, conn);
                 Assert.assertNull(response.getEntity());
-                if (!this.client.keepAlive(response)) {
+                if (!this.client.keepAlive(get, response)) {
                     conn.close();
                     Assert.fail("Connection expected to be re-usable");
                 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
Mon Apr 13 18:31:20 2015
@@ -85,7 +85,7 @@ public class TestHttpService {
         Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
-        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(Boolean.FALSE);
+        Mockito.when(connReuseStrategy.keepAlive(request, response, context)).thenReturn(Boolean.FALSE);
 
         httpservice.handleRequest(conn, context);
 
@@ -121,7 +121,7 @@ public class TestHttpService {
         Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 200, "OK");
         Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
-        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(Boolean.FALSE);
+        Mockito.when(connReuseStrategy.keepAlive(request, response, context)).thenReturn(Boolean.FALSE);
 
         httpservice.handleRequest(conn, context);
 
@@ -146,7 +146,7 @@ public class TestHttpService {
         Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
-        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(Boolean.FALSE);
+        Mockito.when(connReuseStrategy.keepAlive(request, response, context)).thenReturn(Boolean.FALSE);
 
         httpservice.handleRequest(conn, context);
 
@@ -175,7 +175,7 @@ public class TestHttpService {
         Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
-        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(Boolean.FALSE);
+        Mockito.when(connReuseStrategy.keepAlive(request, response, context)).thenReturn(Boolean.FALSE);
 
         httpservice.handleRequest(conn, context);
 
@@ -220,7 +220,7 @@ public class TestHttpService {
         Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 100, context)).thenReturn(resp100);
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
-        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(Boolean.FALSE);
+        Mockito.when(connReuseStrategy.keepAlive(request, response, context)).thenReturn(Boolean.FALSE);
 
         httpservice.handleRequest(conn, context);
 
@@ -277,7 +277,7 @@ public class TestHttpService {
         Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue");
         Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 100, context)).thenReturn(response);
-        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(Boolean.FALSE);
+        Mockito.when(connReuseStrategy.keepAlive(request, response, context)).thenReturn(Boolean.FALSE);
 
         httpservice.handleRequest(conn, context);
 
@@ -324,7 +324,7 @@ public class TestHttpService {
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, 500, "Oppsie");
         Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_0, 500, context)).thenReturn(response);
         Mockito.doThrow(new HttpException("Oopsie")).when(expectationVerifier).verify(request,
resp100, context);
-        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(Boolean.FALSE);
+        Mockito.when(connReuseStrategy.keepAlive(request, response, context)).thenReturn(Boolean.FALSE);
 
         httpservice.handleRequest(conn, context);
 
@@ -368,7 +368,7 @@ public class TestHttpService {
         Mockito.when(handlerResolver.lookup(request, context)).thenReturn(requestHandler);
         Mockito.doThrow(new MethodNotSupportedException("whatever")).when(
                 requestHandler).handle(request, response, context);
-        Mockito.when(connReuseStrategy.keepAlive(error, context)).thenReturn(Boolean.FALSE);
+        Mockito.when(connReuseStrategy.keepAlive(request, error, context)).thenReturn(Boolean.FALSE);
 
         httpservice.handleRequest(conn, context);
 
@@ -411,7 +411,7 @@ public class TestHttpService {
         Mockito.when(handlerResolver.lookup(request, context)).thenReturn(requestHandler);
         Mockito.doThrow(new UnsupportedHttpVersionException()).when(
                 requestHandler).handle(request, response, context);
-        Mockito.when(connReuseStrategy.keepAlive(error, context)).thenReturn(Boolean.FALSE);
+        Mockito.when(connReuseStrategy.keepAlive(request, error, context)).thenReturn(Boolean.FALSE);
 
         httpservice.handleRequest(conn, context);
 
@@ -454,7 +454,7 @@ public class TestHttpService {
         Mockito.when(handlerResolver.lookup(request, context)).thenReturn(requestHandler);
         Mockito.doThrow(new ProtocolException("oh, this world is wrong")).when(
                 requestHandler).handle(request, response, context);
-        Mockito.when(connReuseStrategy.keepAlive(error, context)).thenReturn(Boolean.FALSE);
+        Mockito.when(connReuseStrategy.keepAlive(request, error, context)).thenReturn(Boolean.FALSE);
 
         httpservice.handleRequest(conn, context);
 
@@ -492,7 +492,7 @@ public class TestHttpService {
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
         Mockito.when(handlerResolver.lookup(request, context)).thenReturn(requestHandler);
-        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(Boolean.TRUE);
+        Mockito.when(connReuseStrategy.keepAlive(request, response, context)).thenReturn(Boolean.TRUE);
 
         httpservice.handleRequest(conn, context);
 
@@ -531,7 +531,7 @@ public class TestHttpService {
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NO_CONTENT,
"No Content");
         Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
         Mockito.when(handlerResolver.lookup(request, context)).thenReturn(requestHandler);
-        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(Boolean.TRUE);
+        Mockito.when(connReuseStrategy.keepAlive(request, response, context)).thenReturn(Boolean.TRUE);
 
         httpservice.handleRequest(conn, context);
 
@@ -568,7 +568,7 @@ public class TestHttpService {
         final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
         Mockito.when(responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, 200, context)).thenReturn(response);
         Mockito.when(handlerResolver.lookup(request, context)).thenReturn(requestHandler);
-        Mockito.when(connReuseStrategy.keepAlive(response, context)).thenReturn(Boolean.TRUE);
+        Mockito.when(connReuseStrategy.keepAlive(request, response, context)).thenReturn(Boolean.TRUE);
 
         httpservice.handleRequest(conn, context);
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java?rev=1673256&r1=1673255&r2=1673256&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/testserver/HttpClient.java
Mon Apr 13 18:31:20 2015
@@ -113,8 +113,8 @@ public class HttpClient {
         return response;
     }
 
-    public boolean keepAlive(final HttpResponse response) {
-        return this.connStrategy.keepAlive(response, this.context);
+    public boolean keepAlive(final HttpRequest request, final HttpResponse response) {
+        return this.connStrategy.keepAlive(request, response, this.context);
     }
 
 }



Mime
View raw message