feross / simple-get

Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines
MIT License
401 stars 50 forks source link

feat: do not follow redirects and do not error out #44

Closed alessioalex closed 4 years ago

alessioalex commented 5 years ago

Use cases:

alessioalex commented 5 years ago

@mcollina done!

alessioalex commented 5 years ago

ping @feross

SebastianSchmidt commented 5 years ago

I don't think this feature should be added. So far this module focuses on the essential features - matching the name "simple-get". This new feature is only useful for special use cases. If at some point all imaginable use cases are supported, this module has probably lost its wonderful simplicity. But maybe I misjudge the frequency with which this feature is needed.

alessioalex commented 5 years ago

I think this is a valid and simple use case. Furthermore the change only adds an extra condition (34 chars) to an if statement. I don't think the module should automatically follow redirects no matter the situation.

alessioalex commented 4 years ago

ping @feross

millette commented 4 years ago

What about calling it with

get({url, maxRedirects: 0}, cb)

Maybe just a matter of documentating maxRedirects ?

feross commented 4 years ago

@millette Nice idea to use get({url, maxRedirects: 0}, cb) but an error is thrown when too many redirects have happened, so this just throws an error instead of allowing the user to see the response.

@alessioalex Thanks for the PR, this looks good to me.

feross commented 4 years ago

3.1.0

alessioalex commented 4 years ago

thanks @feross