ciaranj/node-oauth — pull request #138 by pjvds (2013-04-12 12:49:00+00:00)
Title: No follow option

## Why did I change node-oauth?

Currently node-oauth follows redirects by default. This is awesome functionality, but there are situations where that isn't what we want, e.q.:

* You want to write your own retry logic.
* When your oauth providers have [known issues](https://bitbucket.org/site/master/issue/5376/using-a-revoked-oauth-token-results-in-a) for endless redirects.
* When you want to know when a redirect is permanent, so that you can update your location.

## What did I change?

I have added `followRedirects` to the `_defaultClientOptions`. This is set to `true` as default.

In the `_performSecureRequest` method, where the follow redirect logic exists, I've added an extra clause that checks the `followRedirect` property. If this is set to `true` is will behave as it currently does, otherwise it doesn't follow the redirect and the 301 or 302 response is passed to the caller via the callback.

## Why did you pick the name followRedirects?

This name is pretty common in http libraries, for example the [Apache httpClient](http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpMethod.html) has a follow redirects property.

An alternative name is `followLocation` which is used by [CURL](http://curl.haxx.se/docs/httpscripting.html).

## Does it introduce breaking change?

No, the change is backwards compatible and follow redirect logic is still enabled by default. It just introduced the option to opt-out.

## It is covered by tests?

Yes, I've included 4 tests that test the behaviour for the following scenario's:

* `followRedirect` should be `true` by default.
* 301 response should follow redirect when `followRedirects` is true.
* 302 response should follow redirect when `followRedirects` is true.
* 301 response should not follow redirect when `followRedirects` is false.
* 302 response should not follow redirect when `followRedirects` is false.