Skip to content

Commit 4efc880

Browse files
committed
WebSocketServerConfig and HttpCompressionConfig should be null
1 parent 9b84e42 commit 4efc880

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

vertx-core/src/main/java/io/vertx/core/http/HttpServerConfig.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,21 @@ private static TcpServerConfig defaultTcpServerConfig() {
8383
*/
8484
public HttpServerConfig(HttpServerOptions options) {
8585

86-
List<CompressionOptions> compressors = options.getCompression().getCompressors();
87-
if (compressors == null) {
88-
int compressionLevel = options.getCompressionLevel();
89-
compressors = Arrays.asList(StandardCompressionOptions.gzip(compressionLevel, 15, 8), StandardCompressionOptions.deflate(compressionLevel, 15, 8));
86+
HttpCompressionConfig compression;
87+
if (options.isCompressionSupported() || options.isDecompressionSupported()) {
88+
List<CompressionOptions> compressors = options.getCompression().getCompressors();
89+
if (compressors == null) {
90+
int compressionLevel = options.getCompressionLevel();
91+
compressors = Arrays.asList(StandardCompressionOptions.gzip(compressionLevel, 15, 8), StandardCompressionOptions.deflate(compressionLevel, 15, 8));
92+
}
93+
compression = new HttpCompressionConfig();
94+
compression.setCompressionEnabled(options.isCompressionSupported());
95+
compression.setDecompressionEnabled(options.isDecompressionSupported());
96+
compression.setContentSizeThreshold(options.getCompressionContentSizeThreshold());
97+
compression.setCompressors(compressors);
98+
} else {
99+
compression = null;
90100
}
91-
HttpCompressionConfig compression = new HttpCompressionConfig();
92-
compression.setCompressionEnabled(options.isCompressionSupported());
93-
compression.setDecompressionEnabled(options.isDecompressionSupported());
94-
compression.setContentSizeThreshold(options.getCompressionContentSizeThreshold());
95-
compression.setCompressors(compressors);
96101

97102
this.versions = EnumSet.copyOf(DEFAULT_VERSIONS);
98103
this.maxFormAttributeSize = options.getMaxFormAttributeSize();
@@ -125,8 +130,8 @@ public HttpServerConfig() {
125130
this.http1Config = null;
126131
this.http2Config = null;
127132
this.http3Config = null;
128-
this.webSocketConfig = new WebSocketServerConfig();
129-
this.compression = new HttpCompressionConfig();
133+
this.webSocketConfig = null;
134+
this.compression = null;
130135
this.tcpConfig = defaultTcpServerConfig();
131136
this.quicConfig = defaultQuicConfig();
132137
}

vertx-core/src/main/java/io/vertx/core/http/impl/tcp/TcpHttpServer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public synchronized Future<HttpServer> listen(ContextInternal context, SocketAdd
206206
HttpCompressionConfig compression = config.getCompression();
207207
ServerSSLOptions sslOptions = configureSSLOptions(config, this.sslOptions);
208208
NetServerInternal server = new NetServerBuilder(vertx, config.getTcpConfig(), sslOptions)
209-
.fileRegionEnabled(!compression.isCompressionEnabled())
209+
.fileRegionEnabled(compression == null || !compression.isCompressionEnabled())
210210
.cleanable(false)
211211
.protocol("http")
212212
.build();
@@ -230,7 +230,7 @@ public synchronized Future<HttpServer> listen(ContextInternal context, SocketAdd
230230
exceptionHandler,
231231
config.getHttp2Config().getConnectionWindowSize());
232232

233-
List<CompressionOptions> compressors = compression.getCompressors();
233+
List<CompressionOptions> compressors = compression != null ? compression.getCompressors() : null;
234234
HttpServerConnectionInitializer initializer = new HttpServerConnectionInitializer(
235235
listenContext,
236236
context.threadingModel(),
@@ -242,7 +242,7 @@ public synchronized Future<HttpServer> listen(ContextInternal context, SocketAdd
242242
config.getTracingPolicy(),
243243
config.getTcpConfig().getNetworkLogging() != null,
244244
compressors != null ? compressors.toArray(new CompressionOptions[0]) : null,
245-
compression.getContentSizeThreshold(),
245+
compression != null ? compression.getContentSizeThreshold() : 0,
246246
config.isHandle100ContinueAutomatically(),
247247
config.getMaxFormAttributeSize(),
248248
config.getMaxFormFields(),

0 commit comments

Comments
 (0)