diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-09-23 18:05:51 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-09-23 18:05:51 +0200 |
commit | 5a5e0e7121d2c068db33c70e1f26475e42ca7ade (patch) | |
tree | 51401dd330fb26fb92a054f943b9e0b9bd736275 /src | |
parent | 8d90b3fbf160650135fc9658b753e39bb56f1508 (diff) |
use Conversations 1.x.y as user agent string in http upload and download
Diffstat (limited to 'src')
3 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java index 69bb1803..879a5680 100644 --- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java @@ -36,8 +36,8 @@ public abstract class AbstractGenerator { "urn:xmpp:receipts" }; private String mVersion = null; - public final String IDENTITY_NAME = "Conversations"; - public final String IDENTITY_TYPE = "phone"; + protected final String IDENTITY_NAME = "Conversations"; + protected final String IDENTITY_TYPE = "phone"; private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); @@ -54,7 +54,7 @@ public abstract class AbstractGenerator { return this.mVersion; } - protected String getIdentityName() { + public String getIdentityName() { return IDENTITY_NAME + " " + getIdentityVersion(); } diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index 0d202bb9..5fa7bf81 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -181,6 +181,7 @@ public class HttpDownloadConnection implements Transferable { changeStatus(STATUS_CHECKING); HttpURLConnection connection = (HttpURLConnection) mUrl.openConnection(); connection.setRequestMethod("HEAD"); + connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getIdentityName()); if (connection instanceof HttpsURLConnection) { mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, interactive); } @@ -236,6 +237,7 @@ public class HttpDownloadConnection implements Transferable { if (connection instanceof HttpsURLConnection) { mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, interactive); } + connection.setRequestProperty("User-Agent",mXmppConnectionService.getIqGenerator().getIdentityName()); connection.connect(); is = new BufferedInputStream(connection.getInputStream()); file.getParentFile().mkdirs(); diff --git a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java index 38e25e7a..3aa28881 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java @@ -165,6 +165,7 @@ public class HttpUploadConnection implements Transferable { connection.setRequestMethod("PUT"); connection.setFixedLengthStreamingMode((int) file.getExpectedSize()); connection.setRequestProperty("Content-Type", mime == null ? "application/octet-stream" : mime); + connection.setRequestProperty("User-Agent",mXmppConnectionService.getIqGenerator().getIdentityName()); connection.setDoOutput(true); connection.connect(); os = connection.getOutputStream(); |