Class CompressionConfig

java.lang.Object
io.vertx.core.http.CompressionConfig

@Unstable public class CompressionConfig extends Object
HTTP compression configuration.
  • Constructor Details

    • CompressionConfig

      public CompressionConfig()
    • CompressionConfig

      public CompressionConfig(CompressionConfig other)
  • Method Details

    • isCompressionEnabled

      public boolean isCompressionEnabled()
      Returns:
      true if the server supports gzip/deflate compression
    • setCompressionEnabled

      public CompressionConfig setCompressionEnabled(boolean compressionEnabled)
      Set whether the server should support gzip/deflate compression (serving compressed responses to clients advertising support for them with Accept-Encoding header)
      Parameters:
      compressionEnabled - true to enable compression support
      Returns:
      a reference to this, so the API can be used fluently
    • isDecompressionEnabled

      public boolean isDecompressionEnabled()
      Returns:
      true if the server supports decompression
    • setDecompressionEnabled

      public CompressionConfig setDecompressionEnabled(boolean decompressionEnabled)
      Set whether the server supports decompression
      Parameters:
      decompressionEnabled - true if decompression supported
      Returns:
      a reference to this, so the API can be used fluently
    • getContentSizeThreshold

      public int getContentSizeThreshold()
      Returns:
      the compression content size threshold
    • setContentSizeThreshold

      public CompressionConfig setContentSizeThreshold(int contentSizeThreshold)
      Set the compression content size threshold if compression is enabled. This is only applicable for HTTP/1.x response bodies. If the response content size in bytes is greater than this threshold, then the response is compressed. Otherwise, it is not compressed.
      Parameters:
      contentSizeThreshold - integer greater than or equal to 0.
      Returns:
      a reference to this, so the API can be used fluently
    • getCompressors

      public List<CompressionOptions> getCompressors()
      Returns:
      the list of compressor to use
    • setCompressors

      public CompressionConfig setCompressors(List<CompressionOptions> compressors)
      Set the list of compressors.
      Parameters:
      compressors - the list of compressors
      Returns:
      a reference to this, so the API can be used fluently
    • addCompressor

      public CompressionConfig addCompressor(CompressionOptions compressor)
      Add a compressor, if the compressor is already registered, the compressor is updated instead.
      Returns:
      a reference to this, so the API can be used fluently
    • addGzip

      public CompressionConfig addGzip()
      Calls addCompressor(CompressionOptions) with the gzip algorithm configured with default parameters.
      Returns:
      a reference to this, so the API can be used fluently
    • addGzip

      public CompressionConfig addGzip(int compressionLevel)
      Calls addCompressor(CompressionOptions) with the gzip algorithm configured with the specified compressionLevel , default window bits and default mem level.
      Parameters:
      compressionLevel - the compression level, ranged from 1 to 9
      Returns:
      a reference to this, so the API can be used fluently
    • addGzip

      public CompressionConfig addGzip(int compressionLevel, int windowBits, int memLevel)
      Calls addCompressor(CompressionOptions) with the gzip algorithm configured with the specified compressionLevel , specified windowBits and specified memLevel.
      Parameters:
      compressionLevel - the compression level param, ranged from 1 to 9
      windowBits - the window bits param
      memLevel - the mem level param
      Returns:
      a reference to this, so the API can be used fluently
    • addDeflate

      public CompressionConfig addDeflate()
      Calls addCompressor(CompressionOptions) with the deflate algorithm configured with default parameters.
      Returns:
      a reference to this, so the API can be used fluently
    • addDeflate

      public CompressionConfig addDeflate(int compressionLevel)
      Calls addCompressor(CompressionOptions) with the deflate algorithm configured with the specified compressionLevel , default window bits and default mem level.
      Returns:
      a reference to this, so the API can be used fluently
    • addDeflate

      public CompressionConfig addDeflate(int compressionLevel, int windowBits, int memLevel)
      Calls addCompressor(CompressionOptions) with the deflate algorithm configured with the specified compressionLevel , specified windowBits and specified memLevel.
      Parameters:
      compressionLevel - the compression level param, ranged from 1 to 9
      windowBits - the window bits param
      memLevel - the mem level param
      Returns:
      a reference to this, so the API can be used fluently
    • addSnappy

      public CompressionConfig addSnappy()
      Calls addCompressor(CompressionOptions) with the snappy algorithm configured with default parameters.
      Returns:
      a reference to this, so the API can be used fluently
    • addZstd

      public CompressionConfig addZstd()
      Calls addCompressor(CompressionOptions) with the zstd algorithm configured with default parameters.
      Returns:
      a reference to this, so the API can be used fluently
    • addZstd

      public CompressionConfig addZstd(int compressionLevel)
      Calls addCompressor(CompressionOptions) with the zstd algorithm configured with the specified compressionLevel , default block size and default max encode size.
      Parameters:
      compressionLevel - the compression level param
      Returns:
      a reference to this, so the API can be used fluently
    • addZstd

      public CompressionConfig addZstd(int compressionLevel, int blockSize, int maxEncodeSize)
      Calls addCompressor(CompressionOptions) with the zstd algorithm configured with the specified compressionLevel , specified blockSize and specified maxEncodeSize.
      Parameters:
      compressionLevel - the compression level param
      blockSize - the block size param
      maxEncodeSize - the max encode size param
      Returns:
      a reference to this, so the API can be used fluently
    • addBrotli

      public CompressionConfig addBrotli()
      Calls addCompressor(CompressionOptions) with the brotli algorithm configured with default parameters.
      Returns:
      a reference to this, so the API can be used fluently
    • addBrotli

      public CompressionConfig addBrotli(int quality)
      Calls addCompressor(CompressionOptions) with the brotli algorithm configured with the specified quality , default window and default mode.
      Parameters:
      quality - the quality param
      Returns:
      a reference to this, so the API can be used fluently