Using a Proxy Server during testing

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Using a Proxy Server during testing

Lewis John Mcgibbney
Hi All,

The use case is pretty simple, I am trying to set up a Jetty proxy
server, push content to the server then attempt to fetch the content
using a crawler.

I create my proxy server as follows.

+  /**
+   * Creates a new AsyncProxyServlet for Testing a Transparent Jetty Proxy.
+   *
+   * @param port
+   *          port to listen to
+   * @param staticContent
+   *          folder where static content lives
+   * @throws Exception
+   */
+  public static Server createProxy(int port, String staticContent)
throws Exception {
+    Server proxy = new Server();
+    Connector connector = new SocketConnector();
+    connector.setPort( port );
+    proxy.addConnector( connector );
+    Context context = new Context( proxy, "/", 0 );
+    context.addServlet( new ServletHolder( new AsyncProxyServlet() ), "/" );
+    ResourceHandler handler = new ResourceHandler();
+    handler.setResourceBase(staticContent);
+    HandlerList handlers = new HandlerList();
+    handlers.setHandlers(new Handler[]{handler, new DefaultHandler()});
+    proxy.setHandler(handlers);
+    return proxy;
+  }

Can someone please comment on whether this is correct. E.g. will a
fully functioning proxy be running for the duration of the test after
I call

private Server proxy;

proxy = createProxy(port, content)
proxy.start

from my test case?

Additionally, how do I configure the proxy w.r.t blocking some
hosts/sites/pages which the client (fetcher) will have access to? The
reason I ask is that I want to create a white-list of URLs which
should act as exceptions for the proxy server e.g. although they are
on the blacklist, some functionality should be provided to allow ad
hoc white list construction... this is a feature I'm trying to
implement.

One last question... how do I activate user name and password
authentication on a Jetty proxy server?

I realize there are a number of issues here and I greatly appreciate
any feedback in advance.

Kind Regards

Lewis



--
Lewis

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Using a Proxy Server during testing

Lewis John Mcgibbney
Hi,

I should mention, all Jetty libraries I'm using are 6.1.26

Thank you very much.

Regards

Lewis

On Fri, Nov 9, 2012 at 4:12 PM, Lewis John Mcgibbney
<[hidden email]> wrote:
> Hi All,
>
> The use case is pretty simple, I am trying to set up a Jetty proxy
> server, push content to the server then attempt to fetch the content
> using a crawler.
>
> I create my proxy server as follows.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email