@Bean UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() { UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory(); factory.addBuilderCustomizers( builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true)); return factory; }
private void customizeConnectionTimeout( UndertowEmbeddedServletContainerFactory factory, final int connectionTimeout) { factory.addBuilderCustomizers( new UndertowBuilderCustomizer() { @Override public void customize(Builder builder) { builder.setSocketOption(UndertowOptions.NO_REQUEST_TIMEOUT, connectionTimeout); } }); }
private void customizeMaxHttpPostSize( UndertowEmbeddedServletContainerFactory factory, final int maxHttpPostSize) { factory.addBuilderCustomizers( new UndertowBuilderCustomizer() { @Override public void customize(Builder builder) { builder.setServerOption(UndertowOptions.MAX_ENTITY_SIZE, (long) maxHttpPostSize); } }); }
@Bean public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory( ConfigProvider<UndertowConfig> cfg) { int port = cfg.defaultReadConfig().findFirst().get().getPort(); UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory(port); factory.addBuilderCustomizers( (UndertowBuilderCustomizer) builder -> { // (*) builder.setServerOption(UndertowOptions.DECODE_URL, true); builder.setServerOption(UndertowOptions.URL_CHARSET, StandardCharsets.UTF_8.name()); }); factory.addDeploymentInfoCustomizers( (UndertowDeploymentInfoCustomizer) deployment -> { // (*) deployment.setDefaultEncoding(StandardCharsets.UTF_8.name()); }); return factory; }
void customizeUndertow( final ServerProperties serverProperties, UndertowEmbeddedServletContainerFactory factory) { if (this.bufferSize != null) { factory.setBufferSize(this.bufferSize); } if (this.buffersPerRegion != null) { factory.setBuffersPerRegion(this.buffersPerRegion); } if (this.ioThreads != null) { factory.setIoThreads(this.ioThreads); } if (this.workerThreads != null) { factory.setWorkerThreads(this.workerThreads); } if (this.directBuffers != null) { factory.setDirectBuffers(this.directBuffers); } if (this.accesslog.dir != null) { factory.setAccessLogDirectory(this.accesslog.dir); } if (this.accesslog.pattern != null) { factory.setAccessLogPattern(this.accesslog.pattern); } if (this.accesslog.prefix != null) { factory.setAccessLogPrefix(this.accesslog.prefix); } if (this.accesslog.suffix != null) { factory.setAccessLogSuffix(this.accesslog.suffix); } if (this.accesslog.enabled != null) { factory.setAccessLogEnabled(this.accesslog.enabled); } factory.setUseForwardHeaders(serverProperties.getOrDeduceUseForwardHeaders()); if (serverProperties.getMaxHttpHeaderSize() > 0) { customizeMaxHttpHeaderSize(factory, serverProperties.getMaxHttpHeaderSize()); } if (serverProperties.getMaxHttpPostSize() > 0) { customizeMaxHttpPostSize(factory, serverProperties.getMaxHttpPostSize()); } if (serverProperties.getConnectionTimeout() != null) { customizeConnectionTimeout(factory, serverProperties.getConnectionTimeout()); } }
@Override protected void doCustomize(UndertowEmbeddedServletContainerFactory container) { WebsocketDeploymentInfoCustomizer customizer = new WebsocketDeploymentInfoCustomizer(); container.addDeploymentInfoCustomizers(customizer); }