}
}
});
String value1 = "1";
ContentResponse response1 = client.newRequest("localhost", serverConnector.getLocalPort())
.header(name, value1)
.timeout(5, TimeUnit.SECONDS)
.send();
Assert.assertEquals(200, response1.getStatus());
Assert.assertTrue(response1.getHeaders().containsKey(PROXIED_HEADER));
List<HttpCookie> cookies = client.getCookieStore().getCookies();
Assert.assertEquals(1, cookies.size());
Assert.assertEquals(name, cookies.get(0).getName());
Assert.assertEquals(value1, cookies.get(0).getValue());
HttpClient client2 = prepareClient();
String value2 = "2";
ContentResponse response2 = client2.newRequest("localhost", serverConnector.getLocalPort())
.header(name, value2)
.timeout(5, TimeUnit.SECONDS)
.send();
Assert.assertEquals(200, response2.getStatus());
Assert.assertTrue(response2.getHeaders().containsKey(PROXIED_HEADER));
cookies = client2.getCookieStore().getCookies();
Assert.assertEquals(1, cookies.size());
Assert.assertEquals(name, cookies.get(0).getName());
Assert.assertEquals(value2, cookies.get(0).getValue());
// Make a third request to be sure the proxy does not mix cookies
ContentResponse response3 = client.newRequest("localhost", serverConnector.getLocalPort())
.timeout(5, TimeUnit.SECONDS)
.send();
Assert.assertEquals(200, response3.getStatus());
Assert.assertTrue(response3.getHeaders().containsKey(PROXIED_HEADER));
}