Skip to content

Instantly share code, notes, and snippets.

@ngima
Created May 8, 2017 09:15
Show Gist options
  • Save ngima/cc42c13167efcc1390f918031d879a96 to your computer and use it in GitHub Desktop.
Save ngima/cc42c13167efcc1390f918031d879a96 to your computer and use it in GitHub Desktop.
Header Interceptor
public class HeaderInterceptor
implements Interceptor {
@Override
public Response intercept(Chain chain)
throws IOException {
Request request = chain.request();
request = request.newBuilder()
.addHeader("appid", "hello")
.addHeader("deviceplatform", "android")
.removeHeader("User-Agent")
.addHeader("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0")
.build();
Response response = chain.proceed(request);
return response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment