Configure HttpConfiguration Jetty with Spring Download

I am using spring boot (1.2.1 at the moment) and I need to increase the default 8k request header size limit, which lives in the HttpConfiguration class in Jetty. Looking into the JettyEmbeddedServletContainerFactory , which I can get through the EmbeddedServletContainerCustomizer , but can't figure out how to change this.

I also looked at the JettyServerCustomizer - I understand that I can get the Server berth through this, but again - I can’t change the HttpConfiguration here.

Any advice would be highly appreciated.

+5
source share
1 answer

You can use the JettyServerCustomizer to reconfigure the HttpConfiguration , but it is a bit like the Jetty configuration model:

 @Bean public EmbeddedServletContainerCustomizer customizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { if (container instanceof JettyEmbeddedServletContainerFactory) { customizeJetty((JettyEmbeddedServletContainerFactory) container); } } private void customizeJetty(JettyEmbeddedServletContainerFactory jetty) { jetty.addServerCustomizers(new JettyServerCustomizer() { @Override public void customize(Server server) { for (Connector connector : server.getConnectors()) { if (connector instanceof ServerConnector) { HttpConnectionFactory connectionFactory = ((ServerConnector) connector) .getConnectionFactory(HttpConnectionFactory.class); connectionFactory.getHttpConfiguration() .setRequestHeaderSize(16 * 1024); } } } }); } }; } 
+9
source

Source: https://habr.com/ru/post/1212685/


All Articles