HttpClient httpClient = new HttpClient();
httpClient.setCacheMaxSizeKB(100);
IHttpRequest request = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
IHttpResponse resp = httpClient.call(request);
Assert.assertEquals(200, resp.getStatus());
Assert.assertEquals("test", resp.getBlockingBody().readString());
Assert.assertNull(resp.getHeader(CacheHandler.XHEADER_NAME));
QAUtil.sleep(2000);
request = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
request.setHeader("Cache-Control", "max-stale");
resp = httpClient.call(request);
Assert.assertEquals(200, resp.getStatus());
Assert.assertEquals("test", resp.getBlockingBody().readString());
Assert.assertTrue(resp.getHeader(CacheHandler.XHEADER_NAME).startsWith("HIT"));
request = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
request.setHeader("Cache-Control", "max-stale=40");
resp = httpClient.call(request);
Assert.assertEquals(200, resp.getStatus());
Assert.assertEquals("test", resp.getBlockingBody().readString());
Assert.assertTrue(resp.getHeader(CacheHandler.XHEADER_NAME).startsWith("HIT"));
QAUtil.sleep(2000);
request = new GetRequest("http://localhost:" + server.getLocalPort() + "/");
request.setHeader("Cache-Control", "max-stale=1");
resp = httpClient.call(request);
Assert.assertEquals(200, resp.getStatus());
Assert.assertEquals("test", resp.getBlockingBody().readString());
Assert.assertNull(resp.getHeader(CacheHandler.XHEADER_NAME));