Skip to content
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

Support limit of redirects #87

Open
mk-pmb opened this issue Apr 2, 2020 · 4 comments
Open

Support limit of redirects #87

mk-pmb opened this issue Apr 2, 2020 · 4 comments

Comments

@mk-pmb
Copy link

mk-pmb commented Apr 2, 2020

In my case, I want to follow no redirects at all, so I'd set that limit to 0.

@mk-pmb
Copy link
Author

mk-pmb commented Apr 2, 2020

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?

@mikeal
Copy link
Owner

mikeal commented Apr 2, 2020

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.

@amio
Copy link

amio commented Apr 2, 2020

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

@swftvsn
Copy link

swftvsn commented Apr 9, 2020

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.

@savi2w savi2w mentioned this issue Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants