by
3 6

Retrofit2 interceptor to add headers to HTTP requests

Retrofit2 interceptor to add headers to HTTP requests: 
AddHeaderInterceptor.java
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1534234/Retrofit2-interceptor-to-add-headers-to-?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
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()); } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus