Package org.glassfish.grizzly.http
Class CompressionConfig
- java.lang.Object
-
- org.glassfish.grizzly.http.CompressionConfig
-
public final class CompressionConfig extends Object
Compression configuration class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCompressionConfig.CompressionModestatic interfaceCompressionConfig.CompressionModeICommon CompressionMode interface.
-
Constructor Summary
Constructors Constructor Description CompressionConfig()CompressionConfig(CompressionConfig compression)The copy constructor.CompressionConfig(CompressionConfig.CompressionMode compressionMode, int compressionMinSize, Set<String> compressibleMimeTypes, Set<String> noCompressionUserAgents)CompressionConfig(CompressionConfig.CompressionMode compressionMode, int compressionMinSize, Set<String> compressibleMimeTypes, Set<String> noCompressionUserAgents, boolean decompressionEnabled)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancheckMimeType(String contentType)Returns true if the resource with the given content-type could be compressed, or false otherwise.booleancheckUserAgent(HttpRequestPacket request)Returns true if based on this configuration user-agent, specified in theHttpRequestPacket, can receive compressed data.Set<String>getCompressableMimeTypes()Deprecated.Set<String>getCompressibleMimeTypes()Returns the read-only set of the mime-types, which are allowed to be compressed.intgetCompressionMinSize()Returns the minimum size of an entity, which will be compressed.CompressionConfig.CompressionModegetCompressionMode()Returns theCompressionConfig.CompressionMode.Set<String>getNoCompressionUserAgents()Returns the read-only set of the user-agents, which will be always responded with uncompressed are.static booleanisClientSupportCompression(CompressionConfig compressionConfig, HttpRequestPacket request, String[] aliases)Returns true if a client, based on itsHttpRequestPacket, could be responded with compressed data, or false otherwise.booleanisDecompressionEnabled()voidset(CompressionConfig compression)Copies the source CompressionConfig object value into this object.voidsetCompressableMimeTypes(String... compressibleMimeTypes)Deprecated.voidsetCompressableMimeTypes(Set<String> compressibleMimeTypes)Deprecated.voidsetCompressibleMimeTypes(String... compressibleMimeTypes)Sets the set of the mime-types, which are allowed to be compressed.voidsetCompressibleMimeTypes(Set<String> compressibleMimeTypes)Sets the set of the mime-types, which are allowed to be compressed.voidsetCompressionMinSize(int compressionMinSize)Sets the minimum size of an entity, which will be compressed.voidsetCompressionMode(CompressionConfig.CompressionMode mode)Sets theCompressionConfig.CompressionMode.voidsetDecompressionEnabled(boolean decompressionEnabled)If set totruecontent-encoding header for incoming data will be respected and data will be decompressed and the decompressed stream will be passed on.voidsetNoCompressionUserAgents(String... noCompressionUserAgents)Sets the set of the user-agents, which will be always responded with uncompressed data.voidsetNoCompressionUserAgents(Set<String> noCompressionUserAgents)Sets the set of the user-agents, which will be always responded with uncompressed data.
-
-
-
Constructor Detail
-
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 Detail
-
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()
Returns theCompressionConfig.CompressionMode.
-
setCompressionMode
public void setCompressionMode(CompressionConfig.CompressionMode mode)
Sets theCompressionConfig.CompressionMode.
-
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()
Deprecated.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)
Deprecated.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)
Deprecated.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:
trueif decompression of incoming data is enabled.- Since:
- 2.3.29
-
setDecompressionEnabled
public void setDecompressionEnabled(boolean decompressionEnabled)
If set totruecontent-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 itsHttpRequestPacket, could be responded with compressed data, or false otherwise.- Parameters:
compressionConfig-CompressionConfigrequest- client-sideHttpRequestPacketaliases- 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 theHttpRequestPacket, 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.
-
-