[android] Added userAgent const for all mapsme project

This commit is contained in:
Dmitry Donskoy 2018-08-08 17:02:39 +03:00 committed by Aleksey Belousov
parent 5f68a99de9
commit 10f220c076
4 changed files with 7 additions and 4 deletions

View file

@ -8,9 +8,9 @@ import android.text.TextUtils;
import android.util.Pair;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.util.HttpClient;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
import com.mopub.common.util.ResponseHeader;
import java.net.URLEncoder;
@ -51,7 +51,7 @@ public class BookmarksDownloadManager
.Request(dstUri)
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE)
.setTitle(title)
.addRequestHeader(ResponseHeader.USER_AGENT.getKey(), Framework.nativeGetUserAgent())
.addRequestHeader(HttpClient.USER_AGENT, Framework.nativeGetUserAgent())
.setDestinationInExternalFilesDir(mContext, null, dstUri.getLastPathSegment());
return downloadManager.enqueue(request);
}

View file

@ -4,6 +4,7 @@ import android.os.AsyncTask;
import android.util.Base64;
import com.mapswithme.util.Constants;
import com.mapswithme.util.HttpClient;
import com.mapswithme.util.StringUtils;
import com.mapswithme.util.Utils;
import com.mapswithme.util.log.Logger;
@ -146,7 +147,7 @@ class ChunkTask extends AsyncTask<Void, byte[], Integer>
urlConnection.setReadTimeout(TIMEOUT_IN_SECONDS * 1000);
// Set user agent with unique client id
urlConnection.setRequestProperty("User-Agent", mUserAgent);
urlConnection.setRequestProperty(HttpClient.USER_AGENT, mUserAgent);
// Provide authorization credentials
String creds = url.getUserInfo();

View file

@ -57,6 +57,8 @@ public final class HttpClient
// TODO(AlexZ): tune for larger files
private final static int STREAM_BUFFER_SIZE = 1024 * 64;
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.NETWORK);
public static final String USER_AGENT = "User-Agent";
public static Params run(@NonNull final Params p) throws IOException, NullPointerException
{

View file

@ -187,7 +187,7 @@ public final class HttpUploader
private void setHeaders(@NonNull URLConnection connection, long bodyLength)
{
mHeaders.add(new KeyValue("User-Agent", USER_AGENT));
mHeaders.add(new KeyValue(HttpClient.USER_AGENT, USER_AGENT));
mHeaders.add(new KeyValue("App-Version", BuildConfig.VERSION_NAME));
mHeaders.add(new KeyValue("Content-Type", "multipart/form-data; boundary=" + mBoundary));
mHeaders.add(new KeyValue("Content-Length", String.valueOf(bodyLength)));