@Test
  public void testPreserveHost() throws Exception {
    servletRunner = new ServletRunner();

    Properties servletProps = new Properties();
    servletProps.setProperty("http.protocol.handle-redirects", "false");
    servletProps.setProperty(ProxyServlet.P_LOG, "true");
    servletProps.setProperty(ProxyServlet.P_FORWARDEDFOR, "true");
    servletProps.setProperty(ProxyServlet.P_PRESERVEHOST, "true");
    setUpServlet(servletProps);

    sc = servletRunner.newClient();
    sc.getClientProperties().setAutoRedirect(false);//don't want httpunit itself to redirect

    final String HEADER = "Host";
    final String[] proxyHost = new String[1];
    localTestServer.register("/targetPath*", new RequestInfoHandler() {
      public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
    	  proxyHost[0] = request.getHeaders(HEADER)[0].getValue();
        super.handle(request, response, context);
      }
    });

    GetMethodWebRequest req = makeGetMethodRequest(sourceBaseUri);
    req.setHeaderField(HEADER, "SomeHost");
    execAndAssert(req, "");
    assertEquals("SomeHost", proxyHost[0]);
  }
If we're proxying a remote service that tries to set cookies, we need to make sure the cookies are not captured
by the httpclient in the ProxyServlet, otherwise later requests from ALL users will all access the remote proxy
with the same cookie as the first user
src/test/java/org/mitre/dsmiley/httpproxy/ProxyServletTest.java