Reputation: 17888
I'm using spring boot (1.2.1 as of now) and I need to increase the default 8k request header size limit which lives in HttpConfiguration
class in Jetty. Looking into JettyEmbeddedServletContainerFactory
which I can get hold of via EmbeddedServletContainerCustomizer
but can't see the way how to change that.
I did have a look on the JettyServerCustomizer
as well - I understand I can get hold of the jetty Server
via that but again - no way how to change the HttpConfiguration
here.
Any tips will be much appreciated.
Upvotes: 6
Views: 3814
Reputation: 116091
You can use a JettyServerCustomizer
to reconfigure the HttpConfiguration
but it's buried a little bit in Jetty's 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);
}
}
}
});
}
};
}
Upvotes: 13