Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2013-10-04 14:58:55 +0000
committerSimone Bordet2013-10-08 13:06:39 +0000
commit25d9b8704fda35d79dc4cad65d0de239269973f4 (patch)
tree017e52921dbf9bd996323a6435fe1d4826760657 /jetty-proxy
parent8eaedc4a5ee9b211945be59c5d830c64d32716e9 (diff)
downloadorg.eclipse.jetty.project-25d9b8704fda35d79dc4cad65d0de239269973f4.tar.gz
org.eclipse.jetty.project-25d9b8704fda35d79dc4cad65d0de239269973f4.tar.xz
org.eclipse.jetty.project-25d9b8704fda35d79dc4cad65d0de239269973f4.zip
417356 - Add SOCKS support to jetty client.
Big refactoring to allow for additional proxy schemes that work at a lower level than HTTP. Introduced client-side ConnectionFactory, and binding that to a HttpDestination, so that connections to that destination will use the same ConnectionFactory. The destination's ConnectionFactory is now initialized from the proxy configuration and the transport, which is now itself a ConnectionFactory. The proxy configuration has also changed becoming polymorphic by introducing a new ProxyConfiguration.Proxy abstract class, which is implemented as HTTPProxy and can be implemented in future as SOCKS4Proxy (and possibly others).
Diffstat (limited to 'jetty-proxy')
-rw-r--r--jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java11
-rw-r--r--jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java17
2 files changed, 14 insertions, 14 deletions
diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
index 2d356edcde..45c871e0e0 100644
--- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
+++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyServletTest.java
@@ -48,8 +48,9 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpContentResponse;
+import org.eclipse.jetty.client.HttpProxy;
+import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.ProxyConfiguration;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.api.Result;
@@ -110,7 +111,7 @@ public class ProxyServletTest
private HttpClient prepareClient() throws Exception
{
HttpClient result = new HttpClient();
- result.setProxyConfiguration(new ProxyConfiguration("localhost", proxyConnector.getLocalPort()));
+ result.getProxyConfiguration().getProxies().add(new HttpProxy("localhost", proxyConnector.getLocalPort()));
result.start();
return result;
}
@@ -236,7 +237,7 @@ public class ProxyServletTest
prepareProxy(new ProxyServlet());
HttpClient result = new HttpClient();
- result.setProxyConfiguration(new ProxyConfiguration("localhost", proxyConnector.getLocalPort()));
+ result.getProxyConfiguration().getProxies().add(new HttpProxy("localhost", proxyConnector.getLocalPort()));
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName("foo");
threadPool.setMaxThreads(20);
@@ -631,7 +632,7 @@ public class ProxyServletTest
}
});
int port = serverConnector.getLocalPort();
- client.getProxyConfiguration().getExcludedOrigins().add("127.0.0.1:" + port);
+ client.getProxyConfiguration().getProxies().get(0).getExcludedOrigins().add(new Origin("http", "127.0.0.1", port));
// Try with a proxied host
ContentResponse response = client.newRequest("localhost", port)
@@ -865,7 +866,7 @@ public class ProxyServletTest
}
});
- ContentResponse response = client.newRequest("localhost", serverConnector.getLocalPort())
+ client.newRequest("localhost", serverConnector.getLocalPort())
.timeout(5, TimeUnit.SECONDS)
.send();
diff --git a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java
index 01fa37787d..d7b55b41df 100644
--- a/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java
+++ b/jetty-proxy/src/test/java/org/eclipse/jetty/proxy/ProxyTunnellingTest.java
@@ -26,17 +26,16 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.HttpProxy;
import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Destination;
-import org.eclipse.jetty.client.api.ProxyConfiguration;
import org.eclipse.jetty.client.util.FutureResponseListener;
import org.eclipse.jetty.client.util.StringContentProvider;
import org.eclipse.jetty.http.HttpHeader;
@@ -143,7 +142,7 @@ public class ProxyTunnellingTest
startProxy();
HttpClient httpClient = new HttpClient(sslContextFactory);
- httpClient.setProxyConfiguration(new ProxyConfiguration("localhost", proxyPort()));
+ httpClient.getProxyConfiguration().getProxies().add(new HttpProxy("localhost", proxyPort()));
httpClient.start();
try
@@ -172,7 +171,7 @@ public class ProxyTunnellingTest
startProxy();
HttpClient httpClient = new HttpClient(sslContextFactory);
- httpClient.setProxyConfiguration(new ProxyConfiguration("localhost", proxyPort()));
+ httpClient.getProxyConfiguration().getProxies().add(new HttpProxy("localhost", proxyPort()));
httpClient.start();
try
@@ -215,7 +214,7 @@ public class ProxyTunnellingTest
startProxy();
final HttpClient httpClient = new HttpClient(sslContextFactory);
- httpClient.setProxyConfiguration(new ProxyConfiguration("localhost", proxyPort()));
+ httpClient.getProxyConfiguration().getProxies().add(new HttpProxy("localhost", proxyPort()));
httpClient.start();
try
@@ -285,7 +284,7 @@ public class ProxyTunnellingTest
stopProxy();
HttpClient httpClient = new HttpClient(sslContextFactory);
- httpClient.setProxyConfiguration(new ProxyConfiguration("localhost", proxyPort));
+ httpClient.getProxyConfiguration().getProxies().add(new HttpProxy("localhost", proxyPort));
httpClient.start();
try
@@ -317,7 +316,7 @@ public class ProxyTunnellingTest
startProxy();
HttpClient httpClient = new HttpClient(sslContextFactory);
- httpClient.setProxyConfiguration(new ProxyConfiguration("localhost", proxyPort()));
+ httpClient.getProxyConfiguration().getProxies().add(new HttpProxy("localhost", proxyPort()));
httpClient.start();
try
@@ -354,7 +353,7 @@ public class ProxyTunnellingTest
});
HttpClient httpClient = new HttpClient(sslContextFactory);
- httpClient.setProxyConfiguration(new ProxyConfiguration("localhost", proxyPort()));
+ httpClient.getProxyConfiguration().getProxies().add(new HttpProxy("localhost", proxyPort()));
httpClient.start();
try
@@ -394,7 +393,7 @@ public class ProxyTunnellingTest
sslContextFactory.start();
HttpClient httpClient = new HttpClient(sslContextFactory);
- httpClient.setProxyConfiguration(new ProxyConfiguration(proxyHost, proxyPort));
+ httpClient.getProxyConfiguration().getProxies().add(new HttpProxy(proxyHost, proxyPort));
httpClient.start();
try

Back to the top