ranm8 / requestify

Simplifies node HTTP request making.
http://ranm8.github.io/requestify
MIT License
223 stars 55 forks source link

How is redirect getting handled #28

Open Ratnesh-Github opened 9 years ago

Ratnesh-Github commented 9 years ago

Thanks for writing this module. I am making a post call to a server with username and password. The response code returned is 302. I am not able to find how redirect is getting handled in requestify.

tevaum commented 9 years ago

As far as I looked into the source code, redirect is reported as an error to the client code. I think it's this way because requestify should handle 3xx codes, but at the moment, it isn't handling. So if you want to handle them yourself, you should change the isSuccessfull function in lib/Requestify.js from:

return code >= 200 && code < 300;

to

return code >= 200 && code < 400;

With this change, you will get your events to fire up normaly and you can handle 300 codes yourself.

Hope that helps.

I'm planning to contribute more actively to requestify from now on, but I didn't contact the author yet to see if he plans on implementing this kind of stuff...