hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r542225 - in /jakarta/httpcomponents/httpclient/trunk/module-client/src: main/java/org/apache/http/impl/client/ test/java/org/apache/http/impl/conn/ test/java/org/apache/http/localserver/
Date Mon, 28 May 2007 13:34:31 GMT
Author: olegk
Date: Mon May 28 06:34:30 2007
New Revision: 542225

URL: http://svn.apache.org/viewvc?view=rev&rev=542225
Log:
params refactoring, step 6 - Moved param hierarchy building methods to an optional interface
extending HttpParams

Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/ExecReqThread.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/Helper.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestLocalServer.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java?view=diff&rev=542225&r1=542224&r2=542225
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
Mon May 28 06:34:30 2007
@@ -79,6 +79,7 @@
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpParamsLinker;
 import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
@@ -177,7 +178,7 @@
         this.redirectHandler = redirectHandler;
         this.authHandler   = authHandler;
         this.params        = params;
-        this.requestExec   = new HttpRequestExecutor(params);
+        this.requestExec   = new HttpRequestExecutor();
 
         this.managedConn   = null;
         
@@ -254,10 +255,7 @@
         throws HttpException, IOException {
 
         HttpRequest orig = roureq.getRequest();
-        
-        // Link parameter collections to form a hierarchy:
-        // request -> client
-        orig.getParams().setDefaults(this.params);
+        HttpParamsLinker.link(orig, this.params);
 
         // Add default headers
         Collection defHeaders = (Collection) orig.getParams().getParameter(
@@ -335,8 +333,6 @@
                         targetAuthState);
                 context.setAttribute(HttpClientContext.PROXY_AUTH_STATE,
                         proxyAuthState);
-                //@@@ review parameter hierachy building
-                request.getParams().setDefaults(requestExec.getParams());
                 requestExec.preProcess(request, httpProcessor, context);
                 
                 if (orig instanceof AbortableHttpRequest) {
@@ -371,10 +367,7 @@
                     throw ex;
                 }
 
-                // Link parameter collections to form a hierarchy:
-                // response -> client
-                response.getParams().setDefaults(this.params);
-                
+                HttpParamsLinker.link(request, this.params);
                 requestExec.postProcess(response, httpProcessor, context);
                 
                 RoutedRequest followup =
@@ -484,13 +477,13 @@
 
             case RouteDirector.CONNECT_TARGET:
             case RouteDirector.CONNECT_PROXY:
-                managedConn.open(route, context, requestExec.getParams());
+                managedConn.open(route, context, this.params);
                 break;
 
             case RouteDirector.TUNNEL_TARGET:
                 boolean secure = createTunnel(route, context);
                 LOG.debug("Tunnel created");
-                managedConn.tunnelCreated(secure, requestExec.getParams());
+                managedConn.tunnelCreated(secure, this.params);
                 break;
 
             case RouteDirector.TUNNEL_PROXY:
@@ -498,7 +491,7 @@
                     ("Proxy chains are not supported.");
 
             case RouteDirector.LAYER_PROTOCOL:
-                managedConn.layerProtocol(context, requestExec.getParams());
+                managedConn.layerProtocol(context, this.params);
                 break;
 
             case RouteDirector.UNREACHABLE:

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/ExecReqThread.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/ExecReqThread.java?view=diff&rev=542225&r1=542224&r2=542225
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/ExecReqThread.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/ExecReqThread.java
Mon May 28 06:34:30 2007
@@ -102,7 +102,6 @@
 
             HttpRequest request = (HttpRequest) request_spec.context.
                 getAttribute(HttpExecutionContext.HTTP_REQUEST);
-            request.getParams().setDefaults(request_spec.executor.getParams());
             request_spec.executor.preProcess
                 (request, request_spec.processor, request_spec.context);
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/Helper.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/Helper.java?view=diff&rev=542225&r1=542224&r2=542225
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/Helper.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/Helper.java
Mon May 28 06:34:30 2007
@@ -34,6 +34,8 @@
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpParamsLinker;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpExecutionContext;
 import org.apache.http.protocol.HttpProcessor;
@@ -59,6 +61,7 @@
                                        HttpHost target,
                                        HttpRequestExecutor exec,
                                        HttpProcessor proc,
+                                       HttpParams params,
                                        HttpContext ctxt)
         throws Exception {
 
@@ -66,9 +69,10 @@
         ctxt.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, target);
         ctxt.setAttribute(HttpExecutionContext.HTTP_REQUEST, req);
 
-        req.getParams().setDefaults(exec.getParams());
+        HttpParamsLinker.link(req, params);
         exec.preProcess(req, proc, ctxt);
         HttpResponse rsp = exec.execute(req, conn, ctxt);
+        HttpParamsLinker.link(rsp, params);
         exec.postProcess(rsp, proc, ctxt);
 
         return rsp;

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestLocalServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestLocalServer.java?view=diff&rev=542225&r1=542224&r2=542225
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestLocalServer.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestLocalServer.java
Mon May 28 06:34:30 2007
@@ -42,6 +42,7 @@
 import org.apache.http.entity.StringEntity;
 import org.apache.http.localserver.LocalTestServer;
 import org.apache.http.localserver.ServerTestBase;
+import org.apache.http.params.HttpParamsLinker;
 import org.apache.http.protocol.HttpExecutionContext;
 import org.apache.http.util.EntityUtils;
 
@@ -85,12 +86,13 @@
                 HttpExecutionContext.HTTP_TARGET_HOST, target);
         httpContext.setAttribute(
                 HttpExecutionContext.HTTP_REQUEST, request);
-        request.getParams().setDefaults(httpExecutor.getParams());
 
+        HttpParamsLinker.link(request, defaultParams);
         httpExecutor.preProcess
             (request, httpProcessor, httpContext);
         HttpResponse response = httpExecutor.execute
             (request, conn, httpContext);
+        HttpParamsLinker.link(response, defaultParams);
         httpExecutor.postProcess
             (response, httpProcessor, httpContext);
 
@@ -127,12 +129,13 @@
                     HttpExecutionContext.HTTP_TARGET_HOST, target);
             httpContext.setAttribute(
                     HttpExecutionContext.HTTP_REQUEST, request);
-            request.getParams().setDefaults(httpExecutor.getParams());
 
+            HttpParamsLinker.link(request, defaultParams);
             httpExecutor.preProcess
                 (request, httpProcessor, httpContext);
             HttpResponse response = httpExecutor.execute
                 (request, conn, httpContext);
+            HttpParamsLinker.link(response, defaultParams);
             httpExecutor.postProcess
                 (response, httpProcessor, httpContext);
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java?view=diff&rev=542225&r1=542224&r2=542225
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
Mon May 28 06:34:30 2007
@@ -194,8 +194,9 @@
         conn.open(route, httpContext, defaultParams);
 
         // a new context is created for each testcase, no need to reset
-        HttpResponse response = Helper.execute
-            (request, conn, target, httpExecutor, httpProcessor, httpContext);
+        HttpResponse response = Helper.execute(
+                request, conn, target, 
+                httpExecutor, httpProcessor, defaultParams, httpContext);
 
         assertEquals("wrong status in first response",
                      HttpStatus.SC_OK,
@@ -282,8 +283,8 @@
         conn.open(route, httpContext, defaultParams);
 
         // a new context is created for each testcase, no need to reset
-        HttpResponse response = Helper.execute
-            (request, conn, target, httpExecutor, httpProcessor, httpContext);
+        Helper.execute(request, conn, target, 
+                httpExecutor, httpProcessor, defaultParams, httpContext);
 
         // we leave the connection in mid-use
         // it's not really re-usable, but it must be closed anyway
@@ -301,7 +302,6 @@
         // We now drop the hard references to the connection and trigger GC.
         WeakReference wref = new WeakReference(conn);
         conn = null;
-        response = null;
         httpContext = null; // holds a reference to the connection
 
         // Java does not guarantee that this will trigger the GC, but
@@ -338,9 +338,9 @@
         conn.open(route, httpContext, defaultParams);
 
         // a new context is created for each testcase, no need to reset
-        HttpResponse response = Helper.execute
-            (request, conn, target, httpExecutor, httpProcessor, httpContext);
-        byte[] data = EntityUtils.toByteArray(response.getEntity());
+        HttpResponse response = Helper.execute(request, conn, target, 
+                httpExecutor, httpProcessor, defaultParams, httpContext);
+        EntityUtils.toByteArray(response.getEntity());
 
         // release connection after marking it for re-use
         conn.markReusable();

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java?view=diff&rev=542225&r1=542224&r2=542225
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java
Mon May 28 06:34:30 2007
@@ -110,7 +110,6 @@
      */
     protected void setUp() throws Exception {
 
-        boolean newparams = false;
         if (defaultParams == null) {
             defaultParams = new BasicHttpParams(null);
             HttpProtocolParams.setVersion
@@ -121,7 +120,6 @@
                 (defaultParams, "Jakarta-HttpComponents-Test/1.1");
             HttpProtocolParams.setUseExpectContinue
                 (defaultParams, false);
-            newparams = true;
         }
 
         if (supportedSchemes == null) {
@@ -139,8 +137,8 @@
         // the context is created each time, it may get modified by test cases
         httpContext = new HttpExecutionContext(null);
 
-        if ((httpExecutor == null) || newparams) {
-            httpExecutor = new HttpRequestExecutor(defaultParams);
+        if (httpExecutor == null) {
+            httpExecutor = new HttpRequestExecutor();
         }
 
         if (localServer == null) {



Mime
View raw message