1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 01:29:38 +02:00

Enables the HTTP compression in JBOSH

Adds an extra parameter "compressionEnabled" to ConnectionConfiguration
that is used to set the setCompressionEnabled() of BOSHClientConfig
This commit is contained in:
Marcel Heckel 2018-11-08 13:36:45 +01:00
parent b7ea226c56
commit 1ea10831b6
3 changed files with 23 additions and 32 deletions

View file

@ -125,6 +125,8 @@ public abstract class ConnectionConfiguration {
private final Set<String> enabledSaslMechanisms;
private final boolean compressionEnabled;
protected ConnectionConfiguration(Builder<?,?> builder) {
authzid = builder.authzid;
username = builder.username;
@ -162,6 +164,8 @@ public abstract class ConnectionConfiguration {
allowNullOrEmptyUsername = builder.allowEmptyOrNullUsername;
enabledSaslMechanisms = builder.enabledSaslMechanisms;
compressionEnabled = builder.compressionEnabled;
// If the enabledSaslmechanisms are set, then they must not be empty
assert (enabledSaslMechanisms != null ? !enabledSaslMechanisms.isEmpty() : true);
@ -440,8 +444,7 @@ public abstract class ConnectionConfiguration {
* @return true if the connection is going to use stream compression.
*/
public boolean isCompressionEnabled() {
// Compression for non-TCP connections is always disabled
return false;
return compressionEnabled;
}
/**
@ -513,6 +516,7 @@ public abstract class ConnectionConfiguration {
private boolean saslMechanismsSealed;
private Set<String> enabledSaslMechanisms;
private X509TrustManager customX509TrustManager;
private boolean compressionEnabled = false;
protected Builder() {
if (SmackConfiguration.DEBUG) {
@ -946,6 +950,21 @@ public abstract class ConnectionConfiguration {
return getThis();
}
/**
* Sets if the connection is going to use compression (default false).
*
* Compression is only activated if the server offers compression. With compression network
* traffic can be reduced up to 90%. By default compression is disabled.
*
* @param compressionEnabled if the connection is going to use compression on the HTTP level.
* @return a reference to this object.
*/
public B setCompressionEnabled(boolean compressionEnabled) {
this.compressionEnabled = compressionEnabled;
return getThis();
}
public abstract C build();
protected abstract B getThis();