@@ -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 }
0 commit comments