简单的拦截器请求头

public class Logger implements Interceptor{  
    @Override  
    public Response intercept(Chain chain) throws IOException {  
        Request original = chain.request();  
        HttpUrl url=original.url().newBuilder()  
                //需要添加的公共参数,以键值对形式添加
                .addQueryParameter("source","android")  
                .build();  
        //添加请求头  
        Request request = original.newBuilder()  
                .url(url)  
                .build();  
        return chain.proceed(request);  
    }  
} 

你可能感兴趣的:(简单的拦截器请求头)