ContextHandler context = new ContextHandler(); context.setContextPath("/square"); context.setAllowNullPathInfo(true);
contextHandler.setAllowNullPathInfo(true); // disable redirect from /ws to /ws/
public TestServer build() { Server server = new Server(port); ObjectMapper mapper = new ObjectMapper(); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setDirectoriesListed(true); resourceHandler.setResourceBase(baseDir.getAbsolutePath()); resourceHandler.setMinMemoryMappedContentLength(-1); // Causes file locking on Windows ContextHandler rootContext = new ContextHandler(); rootContext.setContextPath("/"); rootContext.setHandler(resourceHandler); ContextHandler packagesContext = new ContextHandler("/packages.json"); packagesContext.setAllowNullPathInfo(true); packagesContext.setHandler(new PackagesHandler(mapper, baseDir)); ContextHandler latestContext = new ContextHandler("/latest.json"); latestContext.setAllowNullPathInfo(true); latestContext.setHandler(new LatestHandler(mapper)); ContextHandler newsContext = new ContextHandler("/news.html"); newsContext.setAllowNullPathInfo(true); newsContext.setHandler(new NewsHandler()); ContextHandlerCollection contexts = new ContextHandlerCollection(); contexts.setHandlers(new Handler[]{packagesContext, latestContext, newsContext, rootContext}); GzipHandler gzip = new GzipHandler(); server.setHandler(gzip); gzip.setHandler(contexts); return new TestServer(server); }
handlerCollection.addHandler(corsContext); if (serviceProtocol == Protocol.SOAP || serviceProtocol == Protocol.JSON_RPC) { corsContext.setAllowNullPathInfo(true); corsContext.setAllowNullPathInfo(false); context.setAllowNullPathInfo(true); } else { context.setAllowNullPathInfo(false);
public void start() throws Exception { server = new Server(port); ContextHandler homeHandler = new ContextHandler(); homeHandler.setContextPath("/"); homeHandler.setHandler(new HomeHandler()); ContextHandler faviconHandler = new ContextHandler(); faviconHandler.setContextPath("/favicon.ico"); faviconHandler.setAllowNullPathInfo(true); faviconHandler.setHandler(new FaviconHandler()); ContextHandler robotsHandler = new ContextHandler(); robotsHandler.setContextPath("/robots.txt"); robotsHandler.setAllowNullPathInfo(true); robotsHandler.setHandler(new RobotsHandler()); ContextHandler stylesheetHandler = new ContextHandler(); stylesheetHandler.setContextPath("/style.css"); stylesheetHandler.setAllowNullPathInfo(true); stylesheetHandler.setHandler(new StylesheetHandler()); ContextHandlerCollection contexts = new ContextHandlerCollection(); contexts.addHandler(homeHandler); contexts.addHandler(faviconHandler); contexts.addHandler(robotsHandler); contexts.addHandler(stylesheetHandler); server.setHandler(contexts); server.start(); }