我有i
代理,每个都有不同的 ip host_i
。
我想提出请求
<host_i>:4444/content
去
localhost:9999/content?proxy=<host_i>
我该怎么做呢?到目前为止,这是我尝试使用嵌入式码头服务器(版本:8.1.10.v20130312)的内容,但它不起作用,我无法弄清楚。我从:http ://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/得到这个例子AsyncProxyServer.java?h=jetty-8
proxyServer = new Server();
Connector connector = new SelectChannelConnector();
connector.setPort(4444);
proxyServer.setConnectors(new Connector[]{connector});
ServletHandler handler = new ServletHandler();
proxyServer.setHandler(handler);
ServletHolder proxy = handler.addServletWithMapping("org.eclipse.jetty.servlets.ProxyServlet", "/");
proxy.setAsyncSupported(true);
proxyServer.start();
这是我使用处理请求的简单框架的代码localhost:9999
:
websiteContainer = new HttpServer();
websiteServer = new ContainerServer(websiteContainer);
websiteConnection = new SocketConnection(websiteServer);
final SocketAddress websiteAddress = new InetSocketAddress(9999);
websiteConnection.connect(websiteAddress);
public class HttpServer implements Container {
@Override
public void handle(final Request request, final Response response) {
// do some stuff here, I have a breakpoint here to test if a request to a proxy made it here
}