use of org.eclipse.jetty.server.handler.MovedContextHandler in project buck by facebook.
the class HttpDownloaderIntegrationTest method startHttpd.
@BeforeClass
public static void startHttpd() throws Exception {
httpd = new HttpdForTests();
httpd.addHandler(new MovedContextHandler(null, "/redirect", "/out"));
httpd.addStaticContent("cheese");
httpd.start();
}
use of org.eclipse.jetty.server.handler.MovedContextHandler in project sonarlint-core by SonarSource.
the class ConnectedModeTest method prepareRedirectServer.
private static void prepareRedirectServer() throws Exception {
redirectPort = NetworkUtils.getNextAvailablePort(InetAddress.getLoopbackAddress());
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
server = new Server(threadPool);
// HTTP Configuration
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSendServerVersion(true);
httpConfig.setSendDateHeader(false);
// Moved handler
MovedContextHandler movedContextHandler = new MovedContextHandler();
movedContextHandler.setPermanent(true);
movedContextHandler.setNewContextURL(ORCHESTRATOR.getServer().getUrl());
server.setHandler(movedContextHandler);
// http connector
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
http.setPort(redirectPort);
server.addConnector(http);
server.start();
}
use of org.eclipse.jetty.server.handler.MovedContextHandler in project selenium_java by sergueik.
the class AngularAndWebDriverTest method before_suite.
@BeforeSuite
public void before_suite() throws Exception {
// Launch Protractor's own test app on http://localhost:8080
((StdErrLog) Log.getRootLogger()).setLevel(StdErrLog.LEVEL_OFF);
webServer = new Server(new QueuedThreadPool(6));
ServerConnector connector = new ServerConnector(webServer, new HttpConnectionFactory());
connector.setPort(8080);
webServer.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[] { "index.html" });
resource_handler.setResourceBase("src/test/webapp");
HandlerList handlers = new HandlerList();
MovedContextHandler effective_symlink = new MovedContextHandler(webServer, "/lib/angular", "/lib/angular_v1.2.9");
handlers.setHandlers(new Handler[] { effective_symlink, resource_handler, new DefaultHandler() });
webServer.setHandler(handlers);
webServer.start();
setupBrowser("chrome");
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
ngWebDriver = new NgWebDriver(driver);
}
use of org.eclipse.jetty.server.handler.MovedContextHandler in project cloudstack by apache.
the class ServerDaemon method createHandlers.
private Pair<SessionHandler, HandlerCollection> createHandlers() {
final WebAppContext webApp = new WebAppContext();
webApp.setContextPath(contextPath);
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
// GZIP handler
final GzipHandler gzipHandler = new GzipHandler();
gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml");
gzipHandler.setIncludedMethods("GET", "POST");
gzipHandler.setCompressionLevel(9);
gzipHandler.setHandler(webApp);
if (StringUtils.isEmpty(webAppLocation)) {
webApp.setWar(getShadedWarUrl());
} else {
webApp.setWar(webAppLocation);
}
// Request log handler
final RequestLogHandler log = new RequestLogHandler();
log.setRequestLog(createRequestLog());
// Redirect root context handler_war
MovedContextHandler rootRedirect = new MovedContextHandler();
rootRedirect.setContextPath("/");
rootRedirect.setNewContextURL(contextPath);
rootRedirect.setPermanent(true);
// Put rootRedirect at the end!
return new Pair<>(webApp.getSessionHandler(), new HandlerCollection(log, gzipHandler, rootRedirect));
}
use of org.eclipse.jetty.server.handler.MovedContextHandler in project neo4j by neo4j.
the class Jetty9WebServer method start.
@Override
public void start() throws Exception {
if (jetty == null) {
verifyAddressConfiguration();
JettyThreadCalculator jettyThreadCalculator = new JettyThreadCalculator(jettyMaxThreads);
jetty = new Server(createQueuedThreadPool(jettyThreadCalculator));
if (httpAddress != null) {
httpConnector = connectorFactory.createConnector(jetty, httpAddress, jettyThreadCalculator);
jetty.addConnector(httpConnector);
}
if (httpsAddress != null) {
if (sslPolicy == null) {
throw new RuntimeException("HTTPS set to enabled, but no SSL policy provided");
}
if (ocspStaplingEnabled) {
// currently the only way to enable OCSP server stapling for JDK is through this property
System.setProperty("jdk.tls.server.enableStatusRequestExtension", "true");
}
httpsConnector = sslSocketFactory.createConnector(jetty, sslPolicy, httpsAddress, jettyThreadCalculator);
jetty.addConnector(httpsConnector);
}
}
handlers = new HandlerList();
jetty.setHandler(handlers);
handlers.addHandler(new MovedContextHandler());
loadAllMounts();
if (requestLog != null) {
loadRequestLogging();
}
startJetty();
}
Aggregations