-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image loads with stock, but can't be loaded with okhttp-integration #436
Comments
I'm not sure where to start here. I'm tempted to just say this is WAI? At least our behavior is consistent with chrome on Android? |
Let me reiterate:
So okhttp-integration doesn't tell the webserver that we're on mobile. |
Ah ok I see what you're saying, thanks. I'll take a look. |
I also didn't check how volley behaves. |
Any chance you could test this locally? It looks like you get a default user agent from system properties, which we could set if no user agent is set in the headers. For example:
|
Actually nevermind, I'll try this myself. |
I put a breakpoint there and executed the code you quoted and it loads with okhttp. |
ok great thanks! |
Volley uses |
where do i add String userAgent = System.getProperty( "http.agent" );
requestBuilder.addHeader("User-Agent", userAgent); it does not fit here public class OkHttpProgressGlideModule implements GlideModule {
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setDecodeFormat(DecodeFormat.ALWAYS_ARGB_8888);
}
@Override
public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(createInterceptor(new DispatchingProgressListener()))
.build();
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
} |
@gikarasojo you don't need to add it anywhere, it's included in the 3.7.0 release. If you want to apply global headers, configure the |
@TWiStErRob am using firebase and i want to download an image from my firebase storage. i just want to download an image with custom sizes, therefore i have this class
and i download like this
am using
|
@TWiStErRob Is there a better way to show percentage download in glide? |
You very likely need to use authenticated access for Firebase, but that's another issue unrelated to this one. Search for "Glide firebase", and open a new issue if you want help. I used OkHttp to show progress. |
Glide Version/Integration library (if any): 3.6.0-SNAPSHOT, 1.3.0-SNAPTSHOT
![image](https://cloud.githubusercontent.com/assets/2906988/7281167/11717290-e928-11e4-80fd-98db2199dedb.png)
Device/Android Version: S4/4.4
Issue details/Repro steps:
If you open this image in any browser or sane app on Laptop it gives HTTP 403. If you open it in Android Chrome or load using the stock android URLConnection it works, but not with okhttp-integration. They probably put a user-agent check there: confirmed with Chrome Dev Tools' device selector.
The weird thing is that the stock method is also using okhttp:
com.android.okhttp.internal.http.HttpURLConnectionImpl
, here's their setup I could fit on a screen:Glide load line:
Stack trace:
The text was updated successfully, but these errors were encountered: