Java Code Examples for org.eclipse.jetty.server.HttpConfiguration#setOutputBufferSize()
The following examples show how to use
org.eclipse.jetty.server.HttpConfiguration#setOutputBufferSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JettySeverTools.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
protected static void addHttpsConnector(Server server, Integer port) throws Exception { SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStorePath(Config.sslKeyStore().getAbsolutePath()); sslContextFactory.setKeyStorePassword(Config.token().getSslKeyStorePassword()); sslContextFactory.setKeyManagerPassword(Config.token().getSslKeyManagerPassword()); sslContextFactory.setTrustAll(true); HttpConfiguration config = new HttpConfiguration(); config.setSecureScheme("https"); config.setOutputBufferSize(32768); config.setRequestHeaderSize(8192 * 2); config.setResponseHeaderSize(8192 * 2); config.setSendServerVersion(true); config.setSendDateHeader(false); ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(config)); sslConnector.setPort(port); server.addConnector(sslConnector); }
Example 2
Source File: AthenzJettyContainer.java From athenz with Apache License 2.0 | 6 votes |
public HttpConfiguration newHttpConfiguration() { // HTTP Configuration boolean sendServerVersion = Boolean.parseBoolean( System.getProperty(AthenzConsts.ATHENZ_PROP_SEND_SERVER_VERSION, "false")); boolean sendDateHeader = Boolean.parseBoolean( System.getProperty(AthenzConsts.ATHENZ_PROP_SEND_DATE_HEADER, "false")); int outputBufferSize = Integer.parseInt( System.getProperty(AthenzConsts.ATHENZ_PROP_OUTPUT_BUFFER_SIZE, "32768")); int requestHeaderSize = Integer.parseInt( System.getProperty(AthenzConsts.ATHENZ_PROP_REQUEST_HEADER_SIZE, "8192")); int responseHeaderSize = Integer.parseInt( System.getProperty(AthenzConsts.ATHENZ_PROP_RESPONSE_HEADER_SIZE, "8192")); HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.setOutputBufferSize(outputBufferSize); httpConfig.setRequestHeaderSize(requestHeaderSize); httpConfig.setResponseHeaderSize(responseHeaderSize); httpConfig.setSendServerVersion(sendServerVersion); httpConfig.setSendDateHeader(sendDateHeader); return httpConfig; }
Example 3
Source File: JettyServerWrapper.java From cougar with Apache License 2.0 | 6 votes |
/** * Sets the request and header buffer sizex if they are not zero */ private void setBufferSizes(HttpConfiguration buffers) { if (requestHeaderSize > 0) { LOGGER.info("Request header size set to {} for {}", requestHeaderSize, buffers.getClass().getCanonicalName()); buffers.setRequestHeaderSize(requestHeaderSize); } if (responseBufferSize > 0) { LOGGER.info("Response buffer size set to {} for {}", responseBufferSize, buffers.getClass().getCanonicalName()); buffers.setOutputBufferSize(responseBufferSize); } if (responseHeaderSize > 0) { LOGGER.info("Response header size set to {} for {}", responseHeaderSize, buffers.getClass().getCanonicalName()); buffers.setResponseHeaderSize(responseHeaderSize); } }
Example 4
Source File: JettySeverTools.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
protected static void addHttpConnector(Server server, Integer port) throws Exception { HttpConfiguration config = new HttpConfiguration(); config.setOutputBufferSize(32768); config.setRequestHeaderSize(8192 * 2); config.setResponseHeaderSize(8192 * 2); config.setSendServerVersion(true); config.setSendDateHeader(false); ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(config)); http.setIdleTimeout(30000); http.setPort(port); server.addConnector(http); }
Example 5
Source File: ConnectorFactory.java From vespa with Apache License 2.0 | 5 votes |
private HttpConnectionFactory newHttpConnectionFactory() { HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.setSendDateHeader(true); httpConfig.setSendServerVersion(false); httpConfig.setSendXPoweredBy(false); httpConfig.setHeaderCacheSize(connectorConfig.headerCacheSize()); httpConfig.setOutputBufferSize(connectorConfig.outputBufferSize()); httpConfig.setRequestHeaderSize(connectorConfig.requestHeaderSize()); httpConfig.setResponseHeaderSize(connectorConfig.responseHeaderSize()); if (connectorConfig.ssl().enabled() || TransportSecurityUtils.isTransportSecurityEnabled()) { // TODO Cleanup once mixed mode is gone httpConfig.addCustomizer(new SecureRequestCustomizer()); } return new HttpConnectionFactory(httpConfig); }
Example 6
Source File: JettyConfigurationHelper.java From attic-polygene-java with Apache License 2.0 | 5 votes |
static void configureHttp( HttpConfiguration httpConfig, JettyConfiguration config ) { // Date header Boolean sendDateHeader = config.sendDateHeader().get(); if( sendDateHeader != null ) { httpConfig.setSendDateHeader( sendDateHeader ); } // Server version Boolean sendServerVersion = config.sendServerVersion().get(); if( sendServerVersion != null ) { httpConfig.setSendServerVersion( sendServerVersion ); } // Header sizes Integer requestHeaderSize = config.requestHeaderSize().get(); if( requestHeaderSize != null ) { httpConfig.setRequestHeaderSize( requestHeaderSize ); } Integer responseHeaderSize = config.responseHeaderSize().get(); if( responseHeaderSize != null ) { httpConfig.setResponseHeaderSize( responseHeaderSize ); } // Buffer sizes Integer responseBufferSize = config.responseBufferSize().get(); if( responseBufferSize != null ) { httpConfig.setOutputBufferSize( responseBufferSize ); } }
Example 7
Source File: ServersUtil.java From joynr with Apache License 2.0 | 5 votes |
private static Server startSSLServer(ContextHandlerCollection contexts, SSLSettings settings, int port) throws IOException, Exception { System.setProperty(MessagingPropertyKeys.PROPERTY_SERVLET_HOST_PATH, "http://localhost:" + port); logger.info("PORT: {}", System.getProperty(MessagingPropertyKeys.PROPERTY_SERVLET_HOST_PATH)); final Server jettyServer = new Server(); HttpConfiguration https_config = new HttpConfiguration(); https_config.setSecureScheme("https"); https_config.setSecurePort(port); https_config.setOutputBufferSize(32768); https_config.addCustomizer(new SecureRequestCustomizer()); // Configure SSL final SslContextFactory contextFactory = new SslContextFactory(); contextFactory.setKeyStorePath(settings.getKeyStorePath()); contextFactory.setTrustStorePath(settings.getTrustStorePath()); contextFactory.setKeyStorePassword(settings.getKeyStorePassword()); contextFactory.setTrustStorePassword(settings.getKeyStorePassword()); contextFactory.setNeedClientAuth(true); // Create and use an SSL connector ServerConnector connector = new ServerConnector(jettyServer, new SslConnectionFactory(contextFactory, "http/1.1"), new HttpConnectionFactory(https_config)); connector.setPort(port); connector.setAcceptQueueSize(1); jettyServer.setConnectors(new Connector[]{ connector }); String serverUrl = "https://localhost:" + port; System.getProperties().setProperty(MessagingPropertyKeys.PROPERTY_SERVLET_HOST_PATH, serverUrl); jettyServer.setHandler(contexts); jettyServer.start(); return jettyServer; }
Example 8
Source File: WebServer.java From pulsar with Apache License 2.0 | 4 votes |
public WebServer(ProxyConfiguration config, AuthenticationService authenticationService) { this.webServiceExecutor = new WebExecutorThreadPool(config.getHttpNumThreads(), "pulsar-external-web"); this.server = new Server(webServiceExecutor); this.authenticationService = authenticationService; this.config = config; List<ServerConnector> connectors = Lists.newArrayList(); HttpConfiguration http_config = new HttpConfiguration(); http_config.setOutputBufferSize(config.getHttpOutputBufferSize()); if (config.getWebServicePort().isPresent()) { this.externalServicePort = config.getWebServicePort().get(); connector = new ServerConnector(server, 1, 1, new HttpConnectionFactory(http_config)); connector.setPort(externalServicePort); connectors.add(connector); } if (config.getWebServicePortTls().isPresent()) { try { SslContextFactory sslCtxFactory; if (config.isTlsEnabledWithKeyStore()) { sslCtxFactory = KeyStoreSSLContext.createSslContextFactory( config.getTlsProvider(), config.getTlsKeyStoreType(), config.getTlsKeyStore(), config.getTlsKeyStorePassword(), config.isTlsAllowInsecureConnection(), config.getTlsTrustStoreType(), config.getTlsTrustStore(), config.getTlsTrustStorePassword(), config.isTlsRequireTrustedClientCertOnConnect(), config.getTlsCertRefreshCheckDurationSec() ); } else { sslCtxFactory = SecurityUtility.createSslContextFactory( config.isTlsAllowInsecureConnection(), config.getTlsTrustCertsFilePath(), config.getTlsCertificateFilePath(), config.getTlsKeyFilePath(), config.isTlsRequireTrustedClientCertOnConnect(), true, config.getTlsCertRefreshCheckDurationSec()); } connectorTls = new ServerConnector(server, 1, 1, sslCtxFactory); connectorTls.setPort(config.getWebServicePortTls().get()); connectors.add(connectorTls); } catch (Exception e) { throw new RuntimeException(e); } } // Limit number of concurrent HTTP connections to avoid getting out of file descriptors connectors.stream().forEach(c -> c.setAcceptQueueSize(1024 / connectors.size())); server.setConnectors(connectors.toArray(new ServerConnector[connectors.size()])); }
Example 9
Source File: SSLUtilsTest.java From athenz with Apache License 2.0 | 4 votes |
private static JettyServer createHttpsJettyServer(boolean clientAuth) throws IOException { Server server = new Server(); HttpConfiguration https_config = new HttpConfiguration(); https_config.setSecureScheme("https"); int port; try (ServerSocket socket = new ServerSocket(0)) { port = socket.getLocalPort(); } https_config.setSecurePort(port); https_config.setOutputBufferSize(32768); SslContextFactory sslContextFactory = new SslContextFactory(); File keystoreFile = new File(DEFAULT_SERVER_KEY_STORE); if (!keystoreFile.exists()) { throw new FileNotFoundException(); } String trustStorePath = DEFAULT_CA_TRUST_STORE; File trustStoreFile = new File(trustStorePath); if (!trustStoreFile.exists()) { throw new FileNotFoundException(); } sslContextFactory.setEndpointIdentificationAlgorithm(null); sslContextFactory.setTrustStorePath(trustStorePath); sslContextFactory.setTrustStoreType(DEFAULT_SSL_STORE_TYPE); sslContextFactory.setTrustStorePassword(DEFAULT_CERT_PWD); sslContextFactory.setKeyStorePath(keystoreFile.getAbsolutePath()); sslContextFactory.setKeyStoreType(DEFAULT_SSL_STORE_TYPE); sslContextFactory.setKeyStorePassword(DEFAULT_CERT_PWD); sslContextFactory.setProtocol(DEFAULT_SSL_PROTOCOL); sslContextFactory.setNeedClientAuth(clientAuth); ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(https_config)); https.setPort(port); https.setIdleTimeout(500000); server.setConnectors(new Connector[] { https }); HandlerList handlers = new HandlerList(); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setBaseResource(Resource.newResource(".")); handlers.setHandlers(new Handler[] { resourceHandler, new DefaultHandler() }); server.setHandler(handlers); return new JettyServer(server, port); }
Example 10
Source File: Start.java From etcd-viewer with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { int timeout = (int) Duration.ONE_HOUR.getMilliseconds(); System.setProperty(WICKET_CFG, CfgType.development.toString()); Server server = new Server(); ServerConnector connector = new ServerConnector(server); // Set some timeout options to make debugging easier. connector.setIdleTimeout(timeout); connector.setSoLingerTime(-1); connector.setPort(8080); server.addConnector(connector); Resource keystore = Resource.newClassPathResource("/keystore"); if (keystore != null && keystore.exists()) { // if a keystore for a SSL certificate is available, start a SSL // connector on port 8443. // By default, the quickstart comes with a Apache Wicket Quickstart // Certificate that expires about half way september 2021. Do not // use this certificate anywhere important as the passwords are // available in the source. SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStoreResource(keystore); sslContextFactory.setKeyStorePassword("wicket"); sslContextFactory.setTrustStoreResource(keystore); sslContextFactory.setKeyManagerPassword("wicket"); // HTTP Configuration HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.setSecureScheme("https"); httpConfig.setSecurePort(8443); httpConfig.setOutputBufferSize(32768); httpConfig.setRequestHeaderSize(8192); httpConfig.setResponseHeaderSize(8192); httpConfig.setSendServerVersion(true); httpConfig.setSendDateHeader(false); // SSL HTTP Configuration HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig); httpsConfig.addCustomizer(new SecureRequestCustomizer()); // SSL Connector ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig)); sslConnector.setPort(8443); server.addConnector(sslConnector); System.out.println("SSL access to the quickstart has been enabled on port 8443"); System.out.println("You can access the application using SSL on https://localhost:8443"); System.out.println(); } WebAppContext bb = new WebAppContext(); bb.setServer(server); bb.setContextPath("/"); bb.setWar("src/main/webapp"); // START JMX SERVER // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); // server.getContainer().addEventListener(mBeanContainer); // mBeanContainer.start(); server.setHandler(bb); try { System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); server.start(); System.in.read(); System.out.println(">>> STOPPING EMBEDDED JETTY SERVER"); server.stop(); server.join(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }
Example 11
Source File: Start.java From wicket-orientdb with Apache License 2.0 | 4 votes |
/** * Main function, starts the jetty server. * * @param args */ public static void main(String[] args) { System.setProperty("wicket.configuration", "development"); Server server = new Server(); HttpConfiguration http_config = new HttpConfiguration(); http_config.setSecureScheme("https"); http_config.setSecurePort(8443); http_config.setOutputBufferSize(32768); ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config)); http.setPort(8080); http.setIdleTimeout(1000 * 60 * 60); server.addConnector(http); Resource keystore = Resource.newClassPathResource("/keystore"); if (keystore != null && keystore.exists()) { // if a keystore for a SSL certificate is available, start a SSL // connector on port 8443. // By default, the quickstart comes with a Apache Wicket Quickstart // Certificate that expires about half way september 2021. Do not // use this certificate anywhere important as the passwords are // available in the source. SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStoreResource(keystore); sslContextFactory.setKeyStorePassword("wicket"); sslContextFactory.setKeyManagerPassword("wicket"); HttpConfiguration https_config = new HttpConfiguration(http_config); https_config.addCustomizer(new SecureRequestCustomizer()); ServerConnector https = new ServerConnector(server, new SslConnectionFactory( sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config)); https.setPort(8443); https.setIdleTimeout(500000); server.addConnector(https); System.out.println("SSL access to the examples has been enabled on port 8443"); System.out .println("You can access the application using SSL on https://localhost:8443"); System.out.println(); } WebAppContext bb = new WebAppContext(); bb.setServer(server); bb.setContextPath("/"); bb.setWar("src/main/webapp"); // uncomment next line if you want to test with JSESSIONID encoded in the urls // ((AbstractSessionManager) // bb.getSessionHandler().getSessionManager()).setUsingCookies(false); server.setHandler(bb); MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); server.addEventListener(mBeanContainer); server.addBean(mBeanContainer); try { server.start(); server.join(); } catch (Exception e) { e.printStackTrace(); System.exit(100); } }
Example 12
Source File: EsigateServer.java From esigate with Apache License 2.0 | 4 votes |
/** * Create and start server. * * @throws Exception * when server cannot be started. */ public static void start() throws Exception { MetricRegistry registry = new MetricRegistry(); QueuedThreadPool threadPool = new InstrumentedQueuedThreadPool(registry); threadPool.setName("esigate"); threadPool.setMaxThreads(maxThreads); threadPool.setMinThreads(minThreads); srv = new Server(threadPool); srv.setStopAtShutdown(true); srv.setStopTimeout(5000); // HTTP Configuration HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.setOutputBufferSize(outputBufferSize); httpConfig.setSendServerVersion(false); Timer processTime = registry.timer("processTime"); try (ServerConnector connector = new InstrumentedServerConnector("main", EsigateServer.port, srv, registry, new InstrumentedConnectionFactory(new HttpConnectionFactory(httpConfig), processTime)); ServerConnector controlConnector = new ServerConnector(srv)) { // Main connector connector.setIdleTimeout(EsigateServer.idleTimeout); connector.setSoLingerTime(-1); connector.setName("main"); connector.setAcceptQueueSize(200); // Control connector controlConnector.setHost("127.0.0.1"); controlConnector.setPort(EsigateServer.controlPort); controlConnector.setName("control"); srv.setConnectors(new Connector[] {connector, controlConnector}); // War ProtectionDomain protectionDomain = EsigateServer.class.getProtectionDomain(); String warFile = protectionDomain.getCodeSource().getLocation().toExternalForm(); String currentDir = new File(protectionDomain.getCodeSource().getLocation().getPath()).getParent(); File workDir = resetTempDirectory(currentDir); WebAppContext context = new WebAppContext(warFile, EsigateServer.contextPath); context.setServer(srv); context.setTempDirectory(workDir); if (StringUtils.isNoneEmpty(sessionCookieName)) { context.getSessionHandler().getSessionCookieConfig().setName(sessionCookieName); } // Add extra classpath (allows to add extensions). if (EsigateServer.extraClasspath != null) { context.setExtraClasspath(EsigateServer.extraClasspath); } // Add the handlers HandlerCollection handlers = new HandlerList(); // control handler must be the first one. // Work in progress, currently disabled. handlers.addHandler(new ControlHandler(registry)); InstrumentedHandler ih = new InstrumentedHandler(registry); ih.setName("main"); ih.setHandler(context); handlers.addHandler(ih); srv.setHandler(handlers); srv.start(); srv.join(); } }
Example 13
Source File: ServerDaemon.java From cloudstack with Apache License 2.0 | 4 votes |
@Override public void start() throws Exception { // Thread pool final QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMinThreads(10); threadPool.setMaxThreads(500); // Jetty Server server = new Server(threadPool); // Setup Scheduler server.addBean(new ScheduledExecutorScheduler()); // Setup JMX final MBeanContainer mbeanContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer()); server.addBean(mbeanContainer); // HTTP config final HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.addCustomizer( new ForwardedRequestCustomizer() ); httpConfig.setSecureScheme("https"); httpConfig.setSecurePort(httpsPort); httpConfig.setOutputBufferSize(32768); httpConfig.setRequestHeaderSize(8192); httpConfig.setResponseHeaderSize(8192); httpConfig.setSendServerVersion(false); httpConfig.setSendDateHeader(false); // HTTP Connector createHttpConnector(httpConfig); // Setup handlers Pair<SessionHandler,HandlerCollection> pair = createHandlers(); server.setHandler(pair.second()); // Extra config options server.setStopAtShutdown(true); // HTTPS Connector createHttpsConnector(httpConfig); server.start(); // Must set the session timeout after the server has started pair.first().setMaxInactiveInterval(sessionTimeout * 60); server.join(); }