Coder Social home page Coder Social logo

Support limit of redirects about bent HOT 4 OPEN

mk-pmb avatar mk-pmb commented on August 22, 2024
Support limit of redirects

from bent.

Comments (4)

swftvsn avatar swftvsn commented on August 22, 2024 5

I'd mirror the fetch spec here and support the three modes also in nodejs:

A request has an associated redirect mode, which is "follow", "error", or "manual". Unless stated otherwise, it is "follow".

"follow"
Follow all redirects incurred when fetching a resource.
"error"
Return a network error when a request is met with a redirect.
"manual"
Retrieves an opaque-redirect filtered response when a request is met with a redirect, to allow a service worker to replay the redirect offline. The response is otherwise indistinguishable from a network error, to not violate atomic HTTP redirect handling.

source: https://fetch.spec.whatwg.org/#requests

It's also specced that:

A redirect status is a status that is 301, 302, 303, 307, or 308.

source: https://fetch.spec.whatwg.org/#statuses

The 20 redirect limit is in the spec:

If request’s redirect count is twenty, return a network error.

source: https://fetch.spec.whatwg.org/#http-redirect-fetch

The browser impl would be just passing that parameter to the fetch, and then tackle the nodejs side with up to 20 redirects. Then it would have full parity.

from bent.

mk-pmb avatar mk-pmb commented on August 22, 2024

Looks like following no redirects is actually the default, and I just made a typo in the URL. Could you please clarify the intended redirect behaviour in the Readme then?

from bent.

mikeal avatar mikeal commented on August 22, 2024

bent doesn’t implement redirect following, although I have considered adding it. But in the browser we use fetch which does its own redirect following, which is why it’s been a bit awkward to figure out how to add this feature to bent in a cross-platform way.

from bent.

amio avatar amio commented on August 22, 2024

I guess we could follow the convention of up to 20 redirects in node side.

from bent.

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.