Giter Site home page Giter Site logo

Support redirects about webimageloader HOT 13 CLOSED

lexs avatar lexs commented on June 27, 2024
Support redirects

from webimageloader.

Comments (13)

lexs avatar lexs commented on June 27, 2024

We do follow redirects but the problem here is that the redirect is from http to https. Here is a StackOverflow post (and Java bug) about this http://stackoverflow.com/a/1884427/253583.

If you change the original url to use https it works for example. Do you think we should manually handle redirects from http to https anyways?

from webimageloader.

orrc avatar orrc commented on June 27, 2024

I'm trying to use redirects (from HTTP to HTTP) and they're not working, and I can't see in the code anywhere where redirects are considered. I get the same stacktrace above, and I can see that no second network is being sent.

I call HttpURLConnection.setFollowRedirects(true); before attempting to load any images.

The only slightly different thing is that the server I'm using is returning HTTP 307 redirects (rather than the more oft-used 301 or 302).

What have I missed? :)

from webimageloader.

orrc avatar orrc commented on June 27, 2024

The answer seems to be the HTTP 307 status code.
http://b.android.com/41739 indicates that the 307 status code isn't properly handled.

I tested this library with the Twitter API URL above (though went from HTTPS to HTTPS) and it worked great.

from webimageloader.

lexs avatar lexs commented on June 27, 2024

The library relies on HttpUrlConnection to handle redirects (which it does by default).

I don't think this it's possible to work around this issue as-is, however I could modify ConnectionHandler to allow for returning a new UrlConnection so you could work around this. Do you want this?

https://github.com/lexs/webimageloader/blob/master/webimageloader/src/main/java/com/webimageloader/ConnectionHandler.java

from webimageloader.

orrc avatar orrc commented on June 27, 2024

Yeah, that sounds good.

I've been thinking about integrating OkHttp anyway, since it fixes some other Android HTTP bugs that I need to deal with. So this would probably work out.

from webimageloader.

lexs avatar lexs commented on June 27, 2024

I wonder if it would be better to actually change the signature to take an URL so your free to use OkHttp if you want instead of having to just throw a connection away? It would still only be called for http(s) though.

from webimageloader.

orrc avatar orrc commented on June 27, 2024

Sounds like a good idea to me!

from webimageloader.

mecid avatar mecid commented on June 27, 2024

is this issue fixed in latest maven build?

from webimageloader.

orrc avatar orrc commented on June 27, 2024

@mecid Which issue specifically? Redirects already work fine with this library; 307 redirects don't work, but that's an Android bug (which I solved by using pull request #17 and OkHttp).

from webimageloader.

mecid avatar mecid commented on June 27, 2024

@orrc this your pull request included in latest maven build?

from webimageloader.

orrc avatar orrc commented on June 27, 2024

@mecid No, the pull request is open; there hasn't been any discussion about it so far. I compiled my own JAR from source.

from webimageloader.

lexs avatar lexs commented on June 27, 2024

It's not merged yet, in the meantime you can clone @orrc repo and compile it yourself.

from webimageloader.

mecid avatar mecid commented on June 27, 2024

I am using okhttp from your sample, but redirects not working.

from webimageloader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.