Search in sources :

Example 1 with MovedContextHandler

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();
}
Also used : HttpdForTests(com.facebook.buck.testutil.integration.HttpdForTests) MovedContextHandler(org.eclipse.jetty.server.handler.MovedContextHandler) BeforeClass(org.junit.BeforeClass)

Example 2 with MovedContextHandler

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();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) Server(org.eclipse.jetty.server.Server) MovedContextHandler(org.eclipse.jetty.server.handler.MovedContextHandler) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration)

Example 3 with MovedContextHandler

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);
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) HandlerList(org.eclipse.jetty.server.handler.HandlerList) StdErrLog(org.eclipse.jetty.util.log.StdErrLog) Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) MovedContextHandler(org.eclipse.jetty.server.handler.MovedContextHandler) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ResourceHandler(org.eclipse.jetty.server.handler.ResourceHandler) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler) BeforeSuite(org.testng.annotations.BeforeSuite)

Example 4 with MovedContextHandler

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));
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) MovedContextHandler(org.eclipse.jetty.server.handler.MovedContextHandler) GzipHandler(org.eclipse.jetty.server.handler.gzip.GzipHandler) RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) Pair(com.cloud.utils.Pair)

Example 5 with MovedContextHandler

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();
}
Also used : HandlerList(org.eclipse.jetty.server.handler.HandlerList) Server(org.eclipse.jetty.server.Server) MovedContextHandler(org.eclipse.jetty.server.handler.MovedContextHandler)

Aggregations

MovedContextHandler (org.eclipse.jetty.server.handler.MovedContextHandler)5 Server (org.eclipse.jetty.server.Server)3 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)2 ServerConnector (org.eclipse.jetty.server.ServerConnector)2 HandlerList (org.eclipse.jetty.server.handler.HandlerList)2 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)2 Pair (com.cloud.utils.Pair)1 HttpdForTests (com.facebook.buck.testutil.integration.HttpdForTests)1 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)1 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)1 HandlerCollection (org.eclipse.jetty.server.handler.HandlerCollection)1 RequestLogHandler (org.eclipse.jetty.server.handler.RequestLogHandler)1 ResourceHandler (org.eclipse.jetty.server.handler.ResourceHandler)1 GzipHandler (org.eclipse.jetty.server.handler.gzip.GzipHandler)1 StdErrLog (org.eclipse.jetty.util.log.StdErrLog)1 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)1 BeforeClass (org.junit.BeforeClass)1 BeforeSuite (org.testng.annotations.BeforeSuite)1