title: How can I use embedded jetty to simulate proxy server?
body: <p>I have <code>i</code> proxies, each with different ip <code>host_i</code>.</p>
  
  <p>I want to make requests to </p>
  
  <p><code>&lt;host_i&gt;:4444/content</code> go to </p>
  
  <p><code>localhost:9999/content?proxy=&lt;host_i&gt;</code> </p>
  
  <p>How do I do this? Here's what I have so far trying to use embedded jetty server (version: 8.1.10.v20130312), but it doesn't work and I can't figure this out. I got this example from: <a href="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" rel="nofollow">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</a></p>
  
  <pre><code>    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();
  </code></pre>
  
  <p>This is my code using simpleframework that handles requests to <code>localhost:9999</code>:</p>
  
  <pre><code>    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
      }
  </code></pre>