mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 04:27:58 +01:00
Merge branch '4.3'
This commit is contained in:
commit
dfae6770af
3 changed files with 23 additions and 1 deletions
|
@ -4,5 +4,7 @@ This API is considered beta quality."""
|
|||
|
||||
dependencies {
|
||||
compile project(':smack-core')
|
||||
compile 'org.igniterealtime.jbosh:jbosh:[0.9,0.10)'
|
||||
// See https://issues.igniterealtime.org/browse/SMACK-858 and
|
||||
// comment in version.gradle why the specify the version this way.
|
||||
compile 'org.igniterealtime.jbosh:jbosh:[0.9.1,0.9.999]'
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smack.bosh;
|
|||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.ConnectionConfiguration;
|
||||
import org.jivesoftware.smack.proxy.ProxyInfo;
|
||||
|
@ -34,6 +36,7 @@ public final class BOSHConfiguration extends ConnectionConfiguration {
|
|||
|
||||
private final boolean https;
|
||||
private final String file;
|
||||
private Map<String, String> httpHeaders;
|
||||
|
||||
private BOSHConfiguration(Builder builder) {
|
||||
super(builder);
|
||||
|
@ -49,6 +52,7 @@ public final class BOSHConfiguration extends ConnectionConfiguration {
|
|||
} else {
|
||||
file = builder.file;
|
||||
}
|
||||
httpHeaders = builder.httpHeaders;
|
||||
}
|
||||
|
||||
public boolean isProxyEnabled() {
|
||||
|
@ -76,6 +80,10 @@ public final class BOSHConfiguration extends ConnectionConfiguration {
|
|||
return new URI((https ? "https://" : "http://") + this.host + ":" + this.port + file);
|
||||
}
|
||||
|
||||
public Map<String, String> getHttpHeaders() {
|
||||
return httpHeaders;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
@ -83,6 +91,7 @@ public final class BOSHConfiguration extends ConnectionConfiguration {
|
|||
public static final class Builder extends ConnectionConfiguration.Builder<Builder, BOSHConfiguration> {
|
||||
private boolean https;
|
||||
private String file;
|
||||
private Map<String, String> httpHeaders = new HashMap<>();
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
@ -101,6 +110,11 @@ public final class BOSHConfiguration extends ConnectionConfiguration {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder addHttpHeader(String name, String value) {
|
||||
httpHeaders.put(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BOSHConfiguration build() {
|
||||
return new BOSHConfiguration(this);
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.PipedReader;
|
|||
import java.io.PipedWriter;
|
||||
import java.io.StringReader;
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -157,8 +158,13 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
if (config.isProxyEnabled()) {
|
||||
cfgBuilder.setProxy(config.getProxyAddress(), config.getProxyPort());
|
||||
}
|
||||
|
||||
cfgBuilder.setCompressionEnabled(config.isCompressionEnabled());
|
||||
|
||||
for (Map.Entry<String, String> h : config.getHttpHeaders().entrySet()) {
|
||||
cfgBuilder.addHttpHeader(h.getKey(), h.getValue());
|
||||
}
|
||||
|
||||
client = BOSHClient.create(cfgBuilder.build());
|
||||
|
||||
client.addBOSHClientConnListener(new BOSHConnectionListener());
|
||||
|
|
Loading…
Reference in a new issue