is there a method to add custom header to request when image is downloaded? I can use volley or okhttp in Glide.
I try add cookie to cookiemanager in okhttpclient, but i
// make sure it's registered in AndroidManifest.xml as described at https://github.com/bumptech/glide/wiki/Configuration#including-a-glidemodule
public class GlideSetup implements GlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { /* no costumization */ }
@Override public void registerComponents(Context context, Glide glide) {
glide.register(String.class, InputStream.class, new HeaderedLoader.Factory());
}
private static class HeaderedLoader extends BaseGlideUrlLoader {
public static final Headers HEADERS = new LazyHeaders.Builder()
.addHeader("User-Agent", USER_AGENT)
.addHeader("App-Agent", APP_AGENT)
.build();
public HeaderedLoader(Context context) {
super(context);
}
@Override protected String getUrl(String model, int width, int height) {
return model;
}
@Override protected Headers getHeaders(String model, int width, int height) {
return HEADERS;
}
public static class Factory implements ModelLoaderFactory {
@Override public StreamModelLoader build(Context context, GenericLoaderFactory factories) {
return new HeaderedLoader(context);
}
@Override public void teardown() { /* nothing to free */ }
}
}
}
and then
....load("http://....")....;