Class CompressionConfig

java.lang.Object
org.glassfish.grizzly.http.CompressionConfig

public final class CompressionConfig extends Object
Compression configuration class.
  • Constructor Details

    • CompressionConfig

      public CompressionConfig()
    • CompressionConfig

      public CompressionConfig(CompressionConfig compression)
      The copy constructor. The newly constructed CompressionConfig object will have the same settings as the source one, but actual values will be independent, so changes to one CompressionConfig object will not affect the other one.
    • CompressionConfig

      public CompressionConfig(CompressionConfig.CompressionMode compressionMode, int compressionMinSize, Set<String> compressibleMimeTypes, Set<String> noCompressionUserAgents)
    • CompressionConfig

      public CompressionConfig(CompressionConfig.CompressionMode compressionMode, int compressionMinSize, Set<String> compressibleMimeTypes, Set<String> noCompressionUserAgents, boolean decompressionEnabled)
  • Method Details

    • set

      public void set(CompressionConfig compression)
      Copies the source CompressionConfig object value into this object. As the result this CompressionConfig object will have the same settings as the source one, but actual values will be independent, so changes to one CompressionConfig object will not affect the other one.
    • getCompressionMode

      public CompressionConfig.CompressionMode getCompressionMode()
    • setCompressionMode

      public void setCompressionMode(CompressionConfig.CompressionMode mode)
    • getCompressionMinSize

      public int getCompressionMinSize()
      Returns the minimum size of an entity, which will be compressed.
    • setCompressionMinSize

      public void setCompressionMinSize(int compressionMinSize)
      Sets the minimum size of an entity, which will be compressed.
    • getCompressableMimeTypes

      @Deprecated public Set<String> getCompressableMimeTypes()
      Returns the read-only set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed.
    • setCompressableMimeTypes

      @Deprecated public void setCompressableMimeTypes(Set<String> compressibleMimeTypes)
      Sets the set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.
    • setCompressableMimeTypes

      @Deprecated public void setCompressableMimeTypes(String... compressibleMimeTypes)
      Sets the set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.
    • getCompressibleMimeTypes

      public Set<String> getCompressibleMimeTypes()
      Returns the read-only set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed.
      Since:
      2.3.29
    • setCompressibleMimeTypes

      public void setCompressibleMimeTypes(Set<String> compressibleMimeTypes)
      Sets the set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.
      Since:
      2.3.29
    • setCompressibleMimeTypes

      public void setCompressibleMimeTypes(String... compressibleMimeTypes)
      Sets the set of the mime-types, which are allowed to be compressed. Empty set means *all* mime-types are allowed to be compressed. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.
      Since:
      2.3.29
    • getNoCompressionUserAgents

      public Set<String> getNoCompressionUserAgents()
      Returns the read-only set of the user-agents, which will be always responded with uncompressed are. Empty set means that compressed data could be sent to *all* user-agents.
    • setNoCompressionUserAgents

      public void setNoCompressionUserAgents(Set<String> noCompressionUserAgents)
      Sets the set of the user-agents, which will be always responded with uncompressed data. Empty set means that compressed data could be sent to *all* user-agents. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.
    • setNoCompressionUserAgents

      public void setNoCompressionUserAgents(String... noCompressionUserAgents)
      Sets the set of the user-agents, which will be always responded with uncompressed data. Empty set means that compressed data could be sent to *all* user-agents. Please note that CompressionConfig object will copy the source Set content, so further changes made on the source Set will not affect CompressionConfig object state.
    • isDecompressionEnabled

      public boolean isDecompressionEnabled()
      Returns:
      true if decompression of incoming data is enabled.
      Since:
      2.3.29
    • setDecompressionEnabled

      public void setDecompressionEnabled(boolean decompressionEnabled)
      If set to true content-encoding header for incoming data will be respected and data will be decompressed and the decompressed stream will be passed on.
      Since:
      2.3.29
    • isClientSupportCompression

      public static boolean isClientSupportCompression(CompressionConfig compressionConfig, HttpRequestPacket request, String[] aliases)
      Returns true if a client, based on its HttpRequestPacket, could be responded with compressed data, or false otherwise.
      Parameters:
      compressionConfig - CompressionConfig
      request - client-side HttpRequestPacket
      aliases - compression algorithm aliases (to match with Accept-Encoding header)
      Returns:
      true if a client, based on its HttpRequestPacket, could be responded with compressed data, or false otherwise
    • checkUserAgent

      public boolean checkUserAgent(HttpRequestPacket request)
      Returns true if based on this configuration user-agent, specified in the HttpRequestPacket, can receive compressed data.
    • checkMimeType

      public boolean checkMimeType(String contentType)
      Returns true if the resource with the given content-type could be compressed, or false otherwise.