Reputation: 3251
Is there a way I can set the send buffer size for the HTTP listener/response sockets created by Tomcat or Jetty? (ie. SO_SNDBUF). Apologies if I'm getting the terminology wrong.
Update:
After googling around and with @Joakim's help I found this:
http://wiki.eclipse.org/Jetty/Howto/Configure_Connectors
and
Slow transfers in Jetty with chunked transfer encoding at certain buffer size
The question then is are the "buffer size" referred by the Jetty.xml config as well as the HttpServletResponse.setBufferSize() the same as the socket "send buffer size"?
Update 2:
Reading more I think neither affect the socket buffer size and its just another buffer the servlet container uses before sending it over to the Socket.
Upvotes: 0
Views: 3202
Reputation: 181
In Jetty 9 with spring it can be done with:
@Configuration
public class CustomJettyConfiguration {
@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()
.setResponseHeaderSize(16 * 1024);
}
}
}
});
}
};
}
}
Upvotes: 1
Reputation: 49452
Jetty has no support for Socket.setSendBufferSize() in any version of Jetty.
You can however, provide your own implementation of a Connector to do just that.
Start by extending SocketConnector in which you provide your own .configure(Socket) implementation that does Socket.setSendBufferSize(int).
Upvotes: 0