GithubHelp home page GithubHelp logo

Comments (3)

iMacTia avatar iMacTia commented on June 2, 2024

Hi @doutatsu, I believe the confusion here is that FollowRedirects only follows "hard" redirects. That's when the server returns one of the 3xx status codes together with a Location header indicating the redirect location (see https://github.com/lostisland/faraday_middleware/blob/main/lib/faraday_middleware/response/follow_redirects.rb#L7).

To my knowledge, those pages you're referring to work differently. The response in that case is a 200 status containing an HTML body (hence why you can see the page on the browser), which normally redirect you to the right page after a few seconds. This uses either a meta tag or a JS snippet to accomplish the redirect.

I'm afraid in such case you'd need to parse the response body (HTML/JS) and look for the redirection url, and this is something outside of the scope of the FollowRedirects middleware.
There might be another middleware accomplishing what you need (though I've never encountered it), or you might write your own middleware and reuse some existing gem that does the heavy lifting in the implementation.

Please let me know if the above helps and if you have any further question!

from faraday_middleware.

doutatsu avatar doutatsu commented on June 2, 2024

Thanks for a detailed response @iMacTia - I was suspecting this, but wanted to double-check. I'll need to see if there is anything in the response with the URL, but I suspect they redirect using JS, which won't work with the plain HTTP request

from faraday_middleware.

iMacTia avatar iMacTia commented on June 2, 2024

Glad that was at least helpful and sorry for not being able to provide an actual solution. I'll close the issue for now but please, should you find a way forward, could you kindly share it here as well? I'm sure other people in future may find it useful 💪.

I'm obviously available to answer any further question as well, especially if you decide to go down the road of writing a middleware 🙌!

from faraday_middleware.

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.