If you're just setting that one property, you can set it on the HttpConfiguration
that was instantiated by default:
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
server.setHandler(new DefaultHandler()); // 404s for everything except favicon.ico
for (Connector c : server.getConnectors()) {
c.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setRequestHeaderSize(65535);
}
server.start();
server.join();
}
You don't have to separately override the HTTPS configuration, because based on your description of what you're currently instantiating, you don't have any HTTPS connectors. Even if you did have an HTTPS connector though, the above loop would work because a ServerConnector
configured for HTTPS would still have an associated HttpConnectionFactory
. You can see how an HTTPS connector would be configured in this example.
However, it really isn't all that much code to set up the necessary objects yourself:
public static void main(String[] args) throws Exception {
Server server = new Server();
server.setHandler(new DefaultHandler()); // 404s for everything except favicon.ico
HttpConfiguration config = new HttpConfiguration();
config.setRequestHeaderSize(65535);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(config));
http.setPort(8080);
server.setConnectors(new Connector[] {http});
server.start();
server.join();
}
I would recommend doing the setup yourself because it'll be easier to maintain if you have other configuration changes in the future.
server.start()
for it to work consistently. – Celina