I need to get the http response headers from image. How to create a interceptor for each request from Glide? Is it necessary create a Glide Module?
Frist, you have to integrate Glide and OkHttp using custom GlideModule instead of the default one.
Refer this example on how to do that.
Then you have to write an OkHttp interceptor to intercept the response information and get the response headers.
Refer this OkHttp Logging Interceptor code and you will get an idea on how to intercept the response and get the response headers.
You have to set that interceptor to your OkHttpClient (which mostly would be a singleton instance):
OkHttpClient okHttpClient = new OkHttpClient.Builder().addInterceptor(yourInterceptor).build();
That OkHttpClient instance has to be passed to your custom GlideModule implementation's registerComponents() callback:
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory( okHttpClient ));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With