ciaranj/node-oauth — pull request #159 by nojhamster (2013-10-07 13:41:21+00:00)
Title: Proxy support and node-request

Proposed solution for https://github.com/ciaranj/node-oauth/issues/158

What I did for both Oauth and Oauth2 :

1) replaced http / https modules by node-request (added in package.json)
2) added support for HTTPS_PROXY and HTTP_PROXY variables
3) added a last parameter to the constructor to provide a proxy (or null to use none)
4) added 5 tests to check those cases :
- if a proxy is given and env vars are set, the given proxy should be used
- if NULL is given as a proxy and env vars are set, no proxy should be used
- if no proxy is given and both HTTPS_PROXY and HTTP_PROXY are set, HTTPS_PROXY should be used
- if no proxy is given and only HTTP_PROXY is set, HTTP_PROXY should be used
- if no proxy is given and no env vars are set, no proxy should be used

In Oauth.js, I changed _createClient() method so that it gets a parsed url object as first parameter and changed tests to use it that way.

Since I added proxy as last parameter, it should remain backward compatible. I tested Oauth2 with passport-github, and Oauth with passport-twitter and that worked fine.

That's all for my proposal. Feel free to give it a try and make comments ;)