Remove the HTTP Server header in Jetty 9

前端 未结 7 1877
执念已碎
执念已碎 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:58

    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);
            }
        }
    }
    

提交回复
热议问题