Set a better User-Agent on requests.

This commit is contained in:
Greyson Parrelli
2020-01-23 12:22:40 -05:00
parent a31da7616d
commit bdb30ebc48
13 changed files with 113 additions and 89 deletions

View File

@@ -0,0 +1,24 @@
package org.thoughtcrime.securesms.net;
import android.os.Build;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.BuildConfig;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Response;
public class UserAgentInterceptor implements Interceptor {
private static final String USER_AGENT = "Signal-Android " + BuildConfig.VERSION_NAME + " (API " + Build.VERSION.SDK_INT + ")";
@Override
public Response intercept(@NonNull Chain chain) throws IOException {
return chain.proceed(chain.request().newBuilder()
.header("User-Agent", USER_AGENT)
.build());
}
}