Comments (4)
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.
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.
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.
I guess we could follow the convention of up to 20 redirects in node side.
from bent.
Related Issues (20)
- Error response body is a still promise HOT 2
- Custom encodings API
- How can I get the response headers (specifically content-type) if I don't specify it? HOT 3
- How to pipe stream HOT 4
- Auth Basic Credentials
- Convert to ES6 Modules HOT 2
- Function to print out full request HOT 2
- query parameters HOT 13
- Response stream events?
- Uploading files with multipart/form-data request HOT 2
- How to attach Client Cert + Key to a request (MTLS) HOT 3
- bent throws on 204 No content response? HOT 4
- StatusError: Payload Too Large HOT 1
- Allow setting method in the client instance HOT 6
- status 201 should not throw error by default HOT 8
- Request headers in DELETE method HOT 1
- POST with 'multipart/form-data' HOT 1
- Error message is not accessible HOT 1
- Switch to undici as the backend on node
- Debugging logging
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bent.