这是您在Jetty 8中隐藏服务器版本的方法:
Server server = new Server(port);
server.setSendServerVersion(false);
Run Code Online (Sandbox Code Playgroud)
你是怎么在Jetty 9做的?所以现在看起来应该是这样的?
HttpConfiguration config = new HttpConfiguration();
config.setSendServerVersion(false);
//TODO: Associate config with server???
Server server = new Server(port);
Run Code Online (Sandbox Code Playgroud)
djs*_*hny 30
在Jetty 9中,您需要在HttpConfiguration上配置它:
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSendServerVersion( false );
HttpConnectionFactory httpFactory = new HttpConnectionFactory( httpConfig );
ServerConnector httpConnector = new ServerConnector( server,httpFactory );
server.setConnectors( new Connector[] { httpConnector } );
Run Code Online (Sandbox Code Playgroud)
Jac*_*cob 23
如果计算出一些似乎有效的代码.不确定它是否正确,但至少它是否有效(:
Server server = new Server(port);
for(Connector y : server.getConnectors()) {
for(ConnectionFactory x : y.getConnectionFactories()) {
if(x instanceof HttpConnectionFactory) {
((HttpConnectionFactory)x).getHttpConfiguration().setSendServerVersion(false);
}
}
}
Run Code Online (Sandbox Code Playgroud)
Tar*_*tor 10
如果将jetty9用作独立服务器,则可以通过jetty.httpConfig.sendServerVersion=false在文件中进行设置来禁用服务器签名start.ini.