Skip to content

Instantly share code, notes, and snippets.

@alejo8591
Forked from voghDev/AddHeaderInterceptor.java
Created November 10, 2016 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alejo8591/8bae59c291f0c5e8d544686612f6061b to your computer and use it in GitHub Desktop.
Save alejo8591/8bae59c291f0c5e8d544686612f6061b to your computer and use it in GitHub Desktop.
Retrofit2 interceptor to add headers to HTTP requests
public class AddHeaderInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request.Builder builder = chain.request().newBuilder();
builder.addHeader("Authorization", "headerContent");
return chain.proceed(builder.build());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment