readrops / Readrops

Android multi-services RSS client
GNU General Public License v3.0
272 stars 20 forks source link

fix: separate OkHttpClient for glide #84

Closed shunf4 closed 3 years ago

shunf4 commented 3 years ago

Sometimes glide requests for feed icon with a wrong URL https://base-url-of-rss-account/path/to/icon instead of https://host-of-icon/path/to/icon because AuthInterceptor has an incorrect state.

Using a separate OkHttpClient for glide could be better.

Shinokuni commented 3 years ago

I was wondering why some icons weren't loading, thanks for finding the cause.

Sadly, having more than one instance of OkHttp is a bad practice. Instantiate an OkHttp client is extensive, it has it own thread pool, etc.

So we need to set the credentials to null before each Glide request. I wonder if Glide provide a callback for this.

This is an annoying issue because as you can't set a retrofit url dynamically, the only way to use one or multiple instance of Retrofit with the same http client is to either rebuild them at each call or set the url at the http client level (for OkHttp with an interceptor).