diff --git a/module-client/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java b/module-client/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java index 60d7d6c0a..a9d24b265 100644 --- a/module-client/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java +++ b/module-client/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java @@ -39,13 +39,12 @@ import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpVersion; import org.apache.http.client.HttpClient; -import org.apache.http.client.RoutedRequest; import org.apache.http.conn.ClientConnectionManager; -import org.apache.http.conn.HttpRoute; import org.apache.http.conn.PlainSocketFactory; import org.apache.http.conn.Scheme; import org.apache.http.conn.SchemeRegistry; import org.apache.http.conn.SocketFactory; +import org.apache.http.conn.params.ConnRoutePNames; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; @@ -101,17 +100,14 @@ public class ClientExecuteProxy { HttpClient client = createHttpClient(); + client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); + HttpRequest req = createRequest(); - final HttpRoute route = new HttpRoute - (target, null, proxy, - supportedSchemes.getScheme(target).isLayered()); - final RoutedRequest roureq = new RoutedRequest.Impl(req, route); - System.out.println("executing request to " + target + " via " + proxy); HttpEntity entity = null; try { - HttpResponse rsp = client.execute(roureq, null); + HttpResponse rsp = client.execute(target, req, null); entity = rsp.getEntity(); System.out.println("----------------------------------------"); diff --git a/module-client/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java b/module-client/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java index ab651f103..710ccee5f 100644 --- a/module-client/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java +++ b/module-client/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java @@ -36,6 +36,7 @@ import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.RoutedRequest; import org.apache.http.client.methods.HttpGet; import org.apache.http.conn.HttpRoute; +import org.apache.http.conn.params.ConnRoutePNames; import org.apache.http.impl.client.DefaultHttpClient; /** @@ -54,16 +55,17 @@ public class ClientProxyAuthentication { HttpHost targetHost = new HttpHost("www.verisign.com", 443, "https"); HttpHost proxy = new HttpHost("localhost", 8080); - HttpRoute route = new HttpRoute(targetHost, null, proxy, true); + + httpclient.getParams().setParameter + (ConnRoutePNames.DEFAULT_PROXY, proxy); HttpGet httpget = new HttpGet("/"); - RoutedRequest routedReq = new RoutedRequest.Impl(httpget, route); - System.out.println("executing request: " + httpget.getRequestLine()); - System.out.println("using route: " + route); + System.out.println("via proxy: " + proxy); + System.out.println("to target: " + targetHost); - HttpResponse response = httpclient.execute(routedReq, null); + HttpResponse response = httpclient.execute(targetHost, httpget, null); HttpEntity entity = response.getEntity(); System.out.println("----------------------------------------"); diff --git a/module-client/src/main/java/org/apache/http/client/HttpClient.java b/module-client/src/main/java/org/apache/http/client/HttpClient.java index c8f908cc0..cff12fa98 100644 --- a/module-client/src/main/java/org/apache/http/client/HttpClient.java +++ b/module-client/src/main/java/org/apache/http/client/HttpClient.java @@ -195,28 +195,4 @@ public interface HttpClient { ; - - /** - * Executes a request along the given route. - * - * @param roureq the request to execute along with the route - * @param context the context to use for the execution, or - * null to use the - * {@link #getDefaultContext default context} - * - * @return the response to the request. See - * {@link #execute(HttpUriRequest,HttpContext)} - * for details. - * - * @deprecated pass just the target instead of a route - * - * @throws HttpException in case of a problem - * @throws IOException in case of an IO problem - * @throws InterruptedException in case of an interrupt - *
timeout exceptions? - */ - HttpResponse execute(RoutedRequest roureq, HttpContext context) - throws HttpException, IOException, InterruptedException - ; - } // interface HttpClient diff --git a/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java b/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java index 14968cdce..927fe699f 100644 --- a/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java +++ b/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java @@ -49,7 +49,6 @@ import org.apache.http.client.CredentialsProvider; import org.apache.http.client.HttpClient; import org.apache.http.client.HttpRequestRetryHandler; import org.apache.http.client.RedirectHandler; -import org.apache.http.client.RoutedRequest; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.HttpRoutePlanner; @@ -457,32 +456,6 @@ public abstract class AbstractHttpClient implements HttpClient { } - //@@@ to be removed with HTTPCLIENT-715 - public final HttpResponse execute(RoutedRequest roureq, - HttpContext context) - throws HttpException, IOException, InterruptedException { - //throw new UnsupportedOperationException("@@@ execute(roureq,context)"); - - if (roureq == null) { - throw new IllegalArgumentException - ("Routed request must not be null."); - } - if (roureq.getRequest() == null) { - throw new IllegalArgumentException - ("Request must not be null."); - } - if (roureq.getRoute() == null) { - throw new IllegalArgumentException - ("Route must not be null."); - } - - //@@@ this is a temporary violation of the API - //@@@ this method will be removed with HTTPCLIENT-715 - return execute(roureq.getRoute().getTargetHost(), - roureq.getRequest(), context); - } - - // non-javadoc, see interface HttpClient public final HttpResponse execute(HttpHost target, HttpRequest request) throws HttpException, IOException, InterruptedException { @@ -543,7 +516,7 @@ public abstract class AbstractHttpClient implements HttpClient { * and the client parameters. *
* This method is called by the default implementation of - * {@link #execute(RoutedRequest,HttpContext)} + * {@link #execute(HttpHost,HttpRequest,HttpContext)} * to obtain the parameters for the * {@link DefaultClientRequestDirector}. * diff --git a/module-client/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java b/module-client/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java index cb2ba6f85..c33775836 100644 --- a/module-client/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java +++ b/module-client/src/test/java/org/apache/http/client/protocol/TestCookie2Support.java @@ -41,7 +41,6 @@ import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.ProtocolVersion; import org.apache.http.client.CookieStore; -import org.apache.http.client.RoutedRequest; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.params.ClientPNames; import org.apache.http.client.params.CookiePolicy; @@ -110,8 +109,7 @@ public class TestCookie2Support extends ServerTestBase { HttpGet httpget = new HttpGet("/test/"); - RoutedRequest request1 = new RoutedRequest.Impl(httpget, getDefaultRoute()); - HttpResponse response1 = client.execute(request1, context); + HttpResponse response1 = client.execute(getServerHttp(), httpget, context); HttpEntity e1 = response1.getEntity(); if (e1 != null) { e1.consumeContent(); @@ -121,8 +119,7 @@ public class TestCookie2Support extends ServerTestBase { assertNotNull(cookies); assertEquals(1, cookies.length); - RoutedRequest request2 = new RoutedRequest.Impl(httpget, getDefaultRoute()); - HttpResponse response2 = client.execute(request2, context); + HttpResponse response2 = client.execute(getServerHttp(), httpget, context); HttpEntity e2 = response2.getEntity(); if (e2 != null) { e2.consumeContent(); @@ -163,8 +160,7 @@ public class TestCookie2Support extends ServerTestBase { HttpGet httpget = new HttpGet("/test/"); - RoutedRequest request1 = new RoutedRequest.Impl(httpget, getDefaultRoute()); - HttpResponse response1 = client.execute(request1, context); + HttpResponse response1 = client.execute(getServerHttp(), httpget, context); HttpEntity e1 = response1.getEntity(); if (e1 != null) { e1.consumeContent(); @@ -174,8 +170,7 @@ public class TestCookie2Support extends ServerTestBase { assertNotNull(cookies); assertEquals(2, cookies.length); - RoutedRequest request2 = new RoutedRequest.Impl(httpget, getDefaultRoute()); - HttpResponse response2 = client.execute(request2, context); + HttpResponse response2 = client.execute(getServerHttp(), httpget, context); HttpEntity e2 = response2.getEntity(); if (e2 != null) { e2.consumeContent(); @@ -214,8 +209,7 @@ public class TestCookie2Support extends ServerTestBase { HttpGet httpget = new HttpGet("/test/"); - RoutedRequest request1 = new RoutedRequest.Impl(httpget, getDefaultRoute()); - HttpResponse response1 = client.execute(request1, context); + HttpResponse response1 = client.execute(getServerHttp(), httpget, context); HttpEntity e1 = response1.getEntity(); if (e1 != null) { e1.consumeContent(); @@ -225,8 +219,7 @@ public class TestCookie2Support extends ServerTestBase { assertNotNull(cookies); assertEquals(1, cookies.length); - RoutedRequest request2 = new RoutedRequest.Impl(httpget, getDefaultRoute()); - HttpResponse response2 = client.execute(request2, context); + HttpResponse response2 = client.execute(getServerHttp(), httpget, context); HttpEntity e2 = response2.getEntity(); if (e2 != null) { e2.consumeContent(); @@ -267,8 +260,7 @@ public class TestCookie2Support extends ServerTestBase { HttpGet httpget = new HttpGet("/test/"); - RoutedRequest request1 = new RoutedRequest.Impl(httpget, getDefaultRoute()); - HttpResponse response1 = client.execute(request1, context); + HttpResponse response1 = client.execute(getServerHttp(), httpget, context); HttpEntity e1 = response1.getEntity(); if (e1 != null) { e1.consumeContent(); diff --git a/module-client/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java b/module-client/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java index 91a2b14fb..b66f332ea 100644 --- a/module-client/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java +++ b/module-client/src/test/java/org/apache/http/impl/client/TestRequestWrapper.java @@ -1,7 +1,7 @@ /* - * $HeadURL:$ - * $Revision:$ - * $Date:$ + * $HeadURL$ + * $Revision$ + * $Date$ * ==================================================================== * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -39,7 +39,6 @@ import org.apache.http.HttpException; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; -import org.apache.http.client.RoutedRequest; import org.apache.http.client.methods.HttpGet; import org.apache.http.entity.StringEntity; import org.apache.http.localserver.ServerTestBase; @@ -50,7 +49,7 @@ import org.apache.http.protocol.HttpRequestHandler; /** * Simple tests for {@link RequestWrapper}. * - * @version $Revision:$ + * @version $Revision$ */ public class TestRequestWrapper extends ServerTestBase { @@ -97,8 +96,7 @@ public class TestRequestWrapper extends ServerTestBase { String s = "http://localhost:" + port + "/path"; HttpGet httpget = new HttpGet(s); - RoutedRequest request = new RoutedRequest.Impl(httpget, getDefaultRoute()); - HttpResponse response = client.execute(request, context); + HttpResponse response = client.execute(getServerHttp(), httpget, context); HttpEntity e = response.getEntity(); if (e != null) { e.consumeContent(); @@ -123,8 +121,7 @@ public class TestRequestWrapper extends ServerTestBase { String s = "http://localhost:" + port; HttpGet httpget = new HttpGet(s); - RoutedRequest request = new RoutedRequest.Impl(httpget, getDefaultRoute()); - HttpResponse response = client.execute(request, context); + HttpResponse response = client.execute(getServerHttp(), httpget, context); HttpEntity e = response.getEntity(); if (e != null) { e.consumeContent();