This is how you hide the server version in Jetty 8:
Server server = new Server(port); server.setSendServerVersion(false);
How do you do it in Jetty 9? So now it should look something like this?
HttpConfiguration config = new HttpConfiguration(); config.setSendServerVersion(false); //TODO: Associate config with server??? Server server = new Server(port);
In Jetty 9, you need to configure it on HttpConfiguration:
HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.setSendServerVersion( false ); HttpConnectionFactory httpFactory = new HttpConnectionFactory( httpConfig ); ServerConnector httpConnector = new ServerConnector( server,httpFactory ); server.setConnectors( new Connector[] { httpConnector } );
If worked out some code that seems to work. Not sure if its right, but at least it works (:
Server server = new Server(port); for(Connector y : server.getConnectors()) { for(ConnectionFactory x : y.getConnectionFactories()) { if(x instanceof HttpConnectionFactory) { ((HttpConnectionFactory)x).getHttpConfiguration().setSendServerVersion(false); } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With