hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rola...@apache.org
Subject svn commit: r603956 - in /jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http: client/ClientRequestDirector.java impl/client/AbstractHttpClient.java impl/client/DefaultClientRequestDirector.java
Date Thu, 13 Dec 2007 17:10:23 GMT
Author: rolandw
Date: Thu Dec 13 09:10:22 2007
New Revision: 603956

URL: http://svn.apache.org/viewvc?rev=603956&view=rev
Log:
HTTPCLIENT-713: remove RoutedRequest from ClientRequestDirector interface

Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/ClientRequestDirector.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/ClientRequestDirector.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/ClientRequestDirector.java?rev=603956&r1=603955&r2=603956&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/ClientRequestDirector.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/ClientRequestDirector.java
Thu Dec 13 09:10:22 2007
@@ -33,9 +33,11 @@
 
 import java.io.IOException;
 
+import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpException;
 import org.apache.http.protocol.HttpContext;
+import org.apache.http.conn.HttpRoute; //@@@ replace by HttpTarget
 import org.apache.http.conn.ManagedClientConnection;
 
 
@@ -78,7 +80,8 @@
      * This is the same behavior as for <code>HttpMethodDirector</code>
      * in HttpClient 3.
      *
-     * @param roureq    the route and request to execute
+     * @param request   the request to execute
+     * @param route     the route to the target of the request
      * @param context   the context for executing the request
      *
      * @return  the final response to the request.
@@ -88,7 +91,8 @@
      * @throws IOException              in case of an IO problem
      * @throws InterruptedException     in case of an interrupt
      */
-    HttpResponse execute(RoutedRequest roureq, HttpContext context)
+    HttpResponse execute(HttpRequest request, HttpRoute route,
+                         HttpContext context)
         throws HttpException, IOException, InterruptedException
         ;
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java?rev=603956&r1=603955&r2=603956&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
Thu Dec 13 09:10:22 2007
@@ -508,7 +508,8 @@
                     determineParams(roureq.getRequest()));
         }
 
-        HttpResponse response = director.execute(roureq, context);
+        HttpResponse response = director.execute(roureq.getRequest(),
+                                                 roureq.getRoute(), context);
         // If the response depends on the connection, the director
         // will have set up an auto-release input stream.
 

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?rev=603956&r1=603955&r2=603956&view=diff
==============================================================================
--- 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
Thu Dec 13 09:10:22 2007
@@ -258,10 +258,13 @@
     
     
     // non-javadoc, see interface ClientRequestDirector
-    public HttpResponse execute(RoutedRequest roureq, HttpContext context)
+    public HttpResponse execute(HttpRequest request, HttpRoute route,
+                                HttpContext context)
         throws HttpException, IOException, InterruptedException {
 
-        HttpRequest orig = roureq.getRequest();
+        RoutedRequest roureq = new RoutedRequest.Impl(request, route);
+
+        final HttpRequest orig = request;
 
         long timeout = HttpClientParams.getConnectionManagerTimeout(params);
         
@@ -271,8 +274,12 @@
         boolean done = false;
         try {
             while (!done) {
+                // In this loop, the RoutedRequest may be replaced by a
+                // followup request and route. The request and route passed
+                // in the method arguments will be replaced. The original
+                // request is still available in 'orig'.
 
-                HttpRoute route = roureq.getRoute();
+                route = roureq.getRoute();
 
                 // Allocate connection if needed
                 if (managedConn == null) {
@@ -303,15 +310,15 @@
                     }
                 }
 
-                // Wrap the original request
-                RequestWrapper request = wrapRequest(roureq.getRequest());
-                request.setParams(this.params);
+                // Wrap the request to be sent, original or followup.
+                RequestWrapper reqwrap = wrapRequest(roureq.getRequest());
+                reqwrap.setParams(this.params);
                 
                 // Re-write request URI if needed
-                rewriteRequestURI(request, route);
+                rewriteRequestURI(reqwrap, route);
                 
                 // Use virtual host if set
-                HttpHost target = (HttpHost) request.getParams().getParameter(
+                HttpHost target = (HttpHost) reqwrap.getParams().getParameter(
                         ClientPNames.VIRTUAL_HOST);
                 
                 if (target == null) {
@@ -331,21 +338,21 @@
                         targetAuthState);
                 context.setAttribute(ClientContext.PROXY_AUTH_STATE,
                         proxyAuthState);
-                requestExec.preProcess(request, httpProcessor, context);
+                requestExec.preProcess(reqwrap, httpProcessor, context);
                 
                 if (orig instanceof AbortableHttpRequest) {
                     ((AbortableHttpRequest) orig).setReleaseTrigger(managedConn);
                 }
 
                 context.setAttribute(ExecutionContext.HTTP_REQUEST,
-                        request);
+                        reqwrap);
 
                 execCount++;
                 try {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Attempt " + execCount + " to execute request");
                     }
-                    response = requestExec.execute(request, managedConn, context);
+                    response = requestExec.execute(reqwrap, managedConn, context);
                     
                 } catch (IOException ex) {
                     LOG.debug("Closing the connection.");
@@ -369,7 +376,7 @@
                 requestExec.postProcess(response, httpProcessor, context);
                 
                 RoutedRequest followup =
-                    handleResponse(roureq, request, response, context);
+                    handleResponse(roureq, reqwrap, response, context);
                 if (followup == null) {
                     done = true;
                 } else {



Mime
View raw message