IHttpServer server = new HttpServer(chain);
server.start();
IBlockingConnection con = new BlockingConnection("localhost", server.getLocalPort());
con.write("GET /test HTTP/1.1\r\n" +
"Host: localhost:" + server.getLocalPort() + "\r\n" +
"User-Agent: me\r\n\r\n");
String header = con.readStringByDelimiter("\r\n\r\n");
Assert.assertTrue(header.indexOf("200") != -1);
Assert.assertFalse(h1.isForwardedRef.get());
h1.reset();
h2.reset();
con.close();
con = new BlockingConnection("localhost", server.getLocalPort());
con.write("GET /bs HTTP/1.1\r\n" +
"Host: localhost:" + server.getLocalPort() + "\r\n" +
"User-Agent: me\r\n\r\n");
header = con.readStringByDelimiter("\r\n\r\n");
Assert.assertTrue(header.indexOf("200") != -1);
Assert.assertTrue(h1.isForwardedRef.get());
Assert.assertFalse(h2.isForwardedRef.get());
con.close();
con.close();
server.close();
}