Server server = new Server(port); for(Connector y : server.getConnectors()) { for(ConnectionFactory x : y.getConnectionFactories()) { if(x instanceof HttpConnectionFactory) { ((HttpConnectionFactory)x).getHttpConfiguration().setSendServerVersion(false); } } }
@Override public void customize(Server server) { ForwardedRequestCustomizer customizer = new ForwardedRequestCustomizer(); for (Connector connector : server.getConnectors()) { for (ConnectionFactory connectionFactory : connector .getConnectionFactories()) { if (connectionFactory instanceof HttpConfiguration.ConnectionFactory) { ((HttpConfiguration.ConnectionFactory) connectionFactory) .getHttpConfiguration().addCustomizer(customizer); } } } }
@Test public void shouldNotSendAServerHeaderForSecurityReasons() throws Exception { HttpConnectionFactory httpConnectionFactory = getHttpConnectionFactory(sslSocketConnector.getConnector().getConnectionFactories()); HttpConfiguration configuration = httpConnectionFactory.getHttpConfiguration(); assertThat(configuration.getSendServerVersion(), is(false)); }
private static Server startHttp1() throws Exception { final Server server = new Server(0); final ServletHandler handler = new ServletHandler(); handler.addServletWithMapping(newServletHolder(thriftServlet), TSERVLET_PATH); handler.addServletWithMapping(newServletHolder(rootServlet), "/"); handler.addFilterWithMapping(new FilterHolder(new ConnectionCloseFilter()), "/*", EnumSet.of(DispatcherType.REQUEST)); server.setHandler(handler); for (Connector c : server.getConnectors()) { for (ConnectionFactory f : c.getConnectionFactories()) { for (String p : f.getProtocols()) { if (p.startsWith("h2c")) { fail("Attempted to create a Jetty server without HTTP/2 support, but failed: " + f.getProtocols()); } } } } server.start(); return server; }
@SuppressWarnings("unchecked") static <T> Collection<T> connectorConnectionFactories(final Connector connector, final Class<T> ofType) { final Collection<T> connectionFactories = newLinkedHashSet(); final ConnectionFactory defaultConnectionFactory = connector.getDefaultConnectionFactory(); if (defaultConnectionFactory != null && ofType.isAssignableFrom(defaultConnectionFactory.getClass())) { connectionFactories.add((T) defaultConnectionFactory); } connectionFactories.addAll(connector.getConnectionFactories().stream() .filter(connectionFactory -> ofType.isAssignableFrom(connectionFactory.getClass())) .map(connectionFactory -> (T) connectionFactory).collect(toList())); return connectionFactories; }
@SuppressWarnings("unchecked") static <T> Collection<T> connectorConnectionFactories(final Connector connector, final Class<T> ofType) { final Collection<T> connectionFactories = newLinkedHashSet(); final ConnectionFactory defaultConnectionFactory = connector.getDefaultConnectionFactory(); if (defaultConnectionFactory != null && ofType.isAssignableFrom(defaultConnectionFactory.getClass())) { connectionFactories.add((T) defaultConnectionFactory); } connectionFactories.addAll(connector.getConnectionFactories().stream() .filter(connectionFactory -> ofType.isAssignableFrom(connectionFactory.getClass())) .map(connectionFactory -> (T) connectionFactory).collect(toList())); return connectionFactories; }
protected int startServer(ContextHandlerCollection contexts, Server jettyServer) throws Exception { ((HttpConnectionFactory) jettyServer.getConnectors()[0].getConnectionFactories().iterator().next()) .getHttpConfiguration().setRequestHeaderSize(30000); jettyServer.setHandler(contexts); if (injector.getInstance(GlobalConfigurationJsonStore.class).get().prometheus_enabled()) { registerPrometheus(); } jettyServer.start(); return ((ServerConnector) jettyServer.getConnectors()[0]).getLocalPort(); }
private static void configureConnectors(Server server) { for (Connector c : server.getConnectors()) { for (ConnectionFactory f : c.getConnectionFactories()) if (f instanceof HttpConnectionFactory) { final HttpConfiguration httpConf = ((HttpConnectionFactory) f).getHttpConfiguration(); httpConf.setSendServerVersion(false); httpConf.setSendDateHeader(false); } } } }
public void configureScanner() throws MojoExecutionException { // use a bigger buffer as Stapler traces can get pretty large on deeply nested URL // this can only be done after server.start() is called, which happens in AbstractJettyMojo.startJetty() // and this configureScanner method is one of the few places that are run afterward. for (Connector con : server.getConnectors()) { for (ConnectionFactory cf : con.getConnectionFactories()) { if (cf instanceof HttpConnectionFactory) { HttpConnectionFactory hcf = (HttpConnectionFactory) cf; hcf.getHttpConfiguration().setResponseHeaderSize(12*1024); } } } setUpScanList(); scannerListeners = new ArrayList<Scanner.BulkListener>(); scannerListeners.add(new Scanner.BulkListener() { public void filesChanged(List<String> changes) { try { restartWebApp(changes.contains(getProject().getFile().getCanonicalPath())); } catch (Exception e) { getLog().error("Error reconfiguring/restarting webapp after change in watched files", e); } } }); }
@Override public void removeCustomizers(Collection<Customizer> customizers) { Connector[] connectors = jettyServer.getConnectors(); for (Connector connector : connectors) { Collection<ConnectionFactory> connectionFactories = connector.getConnectionFactories(); for (ConnectionFactory connectionFactory : connectionFactories) { if (connectionFactory instanceof HttpConnectionFactory) { HttpConnectionFactory httpConnectionFactory = (HttpConnectionFactory) connectionFactory; HttpConfiguration httpConfiguration = httpConnectionFactory.getHttpConfiguration(); List<Customizer> httpConfigurationCustomizers = httpConfiguration.getCustomizers(); httpConfigurationCustomizers.removeAll(customizers); } } } }
@Override public void addCustomizers(Collection<Customizer> customizers) { Connector[] connectors = jettyServer.getConnectors(); for (Connector connector : connectors) { Collection<ConnectionFactory> connectionFactories = connector.getConnectionFactories(); for (ConnectionFactory connectionFactory : connectionFactories) { if (connectionFactory instanceof HttpConnectionFactory) { HttpConnectionFactory httpConnectionFactory = (HttpConnectionFactory) connectionFactory; HttpConfiguration httpConfiguration = httpConnectionFactory.getHttpConfiguration(); if (priorityComparator == null) { for (Customizer customizer : customizers) { httpConfiguration.addCustomizer(customizer); } } else { List<Customizer> httpConfigurationCustomizers = httpConfiguration.getCustomizers(); httpConfigurationCustomizers.addAll(customizers); @SuppressWarnings("unchecked") Comparator<Customizer> comparator = (Comparator<Customizer>) priorityComparator; Collections.sort(httpConfigurationCustomizers, comparator); } } } } }
log.debug("REST headerBufferSize: " + headerBufferSize); for (Connector connector : server.getConnectors()) { for (org.eclipse.jetty.server.ConnectionFactory factory : connector.getConnectionFactories()) { if (factory instanceof HttpConnectionFactory) { log.debug("REST headerBufferSize forced to: " + headerBufferSize);
for (ConnectionFactory cf : y.getConnectionFactories()) { if (cf instanceof HttpConnectionFactory) { HttpConnectionFactory dcf = (HttpConnectionFactory) cf;
for (ConnectionFactory cf : y.getConnectionFactories()) { if (cf instanceof HttpConnectionFactory) { HttpConnectionFactory dcf = (HttpConnectionFactory) cf;
for (ConnectionFactory f : getConnector().getConnectionFactories())
for (ConnectionFactory f : getConnector().getConnectionFactories())