use of io.undertow.server.handlers.cache.DirectBufferCache in project undertow by undertow-io.
the class RangeRequestTestCase method setup.
@BeforeClass
public static void setup() throws URISyntaxException {
Path rootPath = Paths.get(RangeRequestTestCase.class.getResource("range.txt").toURI()).getParent();
PathHandler path = Handlers.path();
path.addPrefixPath("/path", new ByteRangeHandler(new HttpHandler() {
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
exchange.getResponseHeaders().put(Headers.LAST_MODIFIED, DateUtils.toDateString(new Date(10000)));
exchange.getResponseHeaders().put(Headers.ETAG, "\"someetag\"");
exchange.getResponseSender().send("0123456789");
}
}, true));
path.addPrefixPath("/resource", new ResourceHandler(new PathResourceManager(rootPath, 10485760)).setDirectoryListingEnabled(true));
path.addPrefixPath("/cachedresource", new ResourceHandler(new CachingResourceManager(1000, 1000000, new DirectBufferCache(1000, 10, 10000), new PathResourceManager(rootPath, 10485760), -1)).setDirectoryListingEnabled(true));
DefaultServer.setRootHandler(path);
}
Aggregations