Created
October 20, 2017 12:31
-
-
Save amadeu01/0bc9bcceb3bd655187fd9188b8a7f7ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import br.com.agileprocess.agileroutes.BuildConfig; | |
import okhttp3.Interceptor; | |
import okhttp3.Request; | |
import okhttp3.Response; | |
public class UserAgentInterceptor implements Interceptor { | |
public UserAgentInterceptor() {} | |
@Override | |
public Response intercept(Interceptor.Chain chain) throws IOException { | |
Request original = chain.request(); | |
Request.Builder builder = original.newBuilder() | |
.addHeader("User-Agent", System.getProperty("http.agent")) | |
.addHeader("Mobile-Version-Name", BuildConfig.VERSION_NAME) | |
.addHeader("Mobile-Version-Code", String.valueOf(BuildConfig.VERSION_CODE)) | |
.method(original.method(), original.body()); | |
Request request = builder.build(); | |
return chain.proceed(request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment