Remove the HTTP Server header in Jetty 9

前端 未结 7 1863
执念已碎
执念已碎 2020-12-30 01:36

This is how you hide the server version in Jetty 8:

Server server = new Server(port);
server.setSendServerVersion(false);

How do you do it

7条回答
  •  隐瞒了意图╮
    2020-12-30 01:55

    Lambda-style variant of Jacob's solution (which worked for me):

    final Server server = new Server(port);
    Stream.of(server.getConnectors()).flatMap(connector -> connector.getConnectionFactories().stream())
                .filter(connFactory -> connFactory instanceof HttpConnectionFactory)
                .forEach(httpConnFactory -> ((HttpConnectionFactory)httpConnFactory).getHttpConfiguration().setSendServerVersion(false));
    

提交回复
热议问题