[jetty-user] Using a Proxy Server during testing
Lewis John Mcgibbney <[email protected]> Fri, 9 Nov 2012 16:12:23 +0000
| Newsgroups | gmane.comp.java.jetty.support |
|---|---|
| Message-ID | <CAGaRif0ehVMkH0475fve8A7m_7DoGyLneYoqF1EOQjEL7RAUqw@mail.gmail.com> |
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