mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-24 23:32:05 +01:00
Don't log a compression releated warning
if the server doesn't support stream compression.
This commit is contained in:
parent
7b1b20a13c
commit
181d58c996
1 changed files with 12 additions and 11 deletions
|
@ -371,9 +371,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
|
|
||||||
// If compression is enabled then request the server to use stream compression. XEP-170
|
// If compression is enabled then request the server to use stream compression. XEP-170
|
||||||
// recommends to perform stream compression before resource binding.
|
// recommends to perform stream compression before resource binding.
|
||||||
if (config.isCompressionEnabled()) {
|
maybeEnableCompression();
|
||||||
useCompression();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSmResumptionPossible()) {
|
if (isSmResumptionPossible()) {
|
||||||
smResumedSyncPoint.sendAndWaitForResponse(new Resume(clientHandledStanzasCount, smSessionId));
|
smResumedSyncPoint.sendAndWaitForResponse(new Resume(clientHandledStanzasCount, smSessionId));
|
||||||
|
@ -739,12 +737,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
* @return a instance of XMPPInputOutputStream or null if no suitable instance was found
|
* @return a instance of XMPPInputOutputStream or null if no suitable instance was found
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private XMPPInputOutputStream maybeGetCompressionHandler() {
|
private XMPPInputOutputStream maybeGetCompressionHandler(Compress.Feature compression) {
|
||||||
Compress.Feature compression = getFeature(Compress.Feature.ELEMENT, Compress.NAMESPACE);
|
|
||||||
if (compression == null) {
|
|
||||||
// Server does not support compression
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
for (XMPPInputOutputStream handler : SmackConfiguration.getCompresionHandlers()) {
|
for (XMPPInputOutputStream handler : SmackConfiguration.getCompresionHandlers()) {
|
||||||
String method = handler.getCompressionMethod();
|
String method = handler.getCompressionMethod();
|
||||||
if (compression.getMethods().contains(method))
|
if (compression.getMethods().contains(method))
|
||||||
|
@ -776,11 +769,19 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
* @throws NoResponseException
|
* @throws NoResponseException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
private void useCompression() throws NotConnectedException, NoResponseException, XMPPException, InterruptedException {
|
private void maybeEnableCompression() throws NotConnectedException, NoResponseException, XMPPException, InterruptedException {
|
||||||
|
if (!config.isCompressionEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
maybeCompressFeaturesReceived.checkIfSuccessOrWait();
|
maybeCompressFeaturesReceived.checkIfSuccessOrWait();
|
||||||
|
Compress.Feature compression = getFeature(Compress.Feature.ELEMENT, Compress.NAMESPACE);
|
||||||
|
if (compression == null) {
|
||||||
|
// Server does not support compression
|
||||||
|
return;
|
||||||
|
}
|
||||||
// If stream compression was offered by the server and we want to use
|
// If stream compression was offered by the server and we want to use
|
||||||
// compression then send compression request to the server
|
// compression then send compression request to the server
|
||||||
if ((compressionHandler = maybeGetCompressionHandler()) != null) {
|
if ((compressionHandler = maybeGetCompressionHandler(compression)) != null) {
|
||||||
compressSyncPoint.sendAndWaitForResponseOrThrow(new Compress(compressionHandler.getCompressionMethod()));
|
compressSyncPoint.sendAndWaitForResponseOrThrow(new Compress(compressionHandler.getCompressionMethod()));
|
||||||
} else {
|
} else {
|
||||||
LOGGER.warning("Could not enable compression because no matching handler/method pair was found");
|
LOGGER.warning("Could not enable compression because no matching handler/method pair was found");
|
||||||
|
|
Loading…
Reference in a new issue