set HTTP User Agent to "F-Droid"

First, this is more honest than just using the default since it is saying
what the actual software is.  Second, it protects identity, since the
default User Agent on Android can have a lot of info in it, for example:

"Dalvik/2.1.0 (Linux; U; Android 5.1; XT1039 Build/LPBS23.13-17.3-1)"
This commit is contained in:
Hans-Christoph Steiner 2016-11-10 16:54:27 +01:00
parent ab1e869ebe
commit 6545a26e31

View File

@ -3,6 +3,7 @@ package org.fdroid.fdroid.net;
import com.nostra13.universalimageloader.core.download.BaseImageDownloader; import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.Utils;
import org.spongycastle.util.encoders.Base64; import org.spongycastle.util.encoders.Base64;
@ -116,6 +117,8 @@ public class HttpDownloader extends Downloader {
connection = NetCipher.getHttpURLConnection(sourceUrl); connection = NetCipher.getHttpURLConnection(sourceUrl);
} }
connection.setRequestProperty("User-Agent", "F-Droid " + BuildConfig.VERSION_NAME);
if (username != null && password != null) { if (username != null && password != null) {
// add authorization header from username / password if set // add authorization header from username / password if set
String authString = username + ":" + password; String authString = username + ":" + password;