Fixed bug where headers where being reused between requests

The reuse of headers was especially problematic for the Content-Length header which is only recalculated when it wasn't already set.
Added missing comma to prevent apiConfig from becoming unintentionally global.
encode URI params.

This fixes the error of an malformed URL when a :param has empty spaces.

For example, having /api/:param/ with param="a b" will generate the request
"GET /api/a b  HTTP/1.1" and the target application will read as url the value
"/api/a".
When requesting the Access token from the token URL via the authorization-code flow, the initial referer is stored in redis. The specified referrer_uri when making the token call should be the same as the intially set referrer (/oauth2Success/). A provider doing a check on the referrer will reject token request
Defined content-type for OAuth 2.0 (Client Credentials) request.
Allow API definition dir to be configured in config.json
making redirectURL same for Oauth2
Merge pull request #111 from brightbot/master

Invalid redirect_uri in token request
Update documentation to answer questions from issue #112 & issue #118
Merge pull request #140 from mtougeron/issue-112

Update documentation to answer questions from issue #112 & issue #118
Allow you to change the redis db name in the config. Fixes Issue #40
Merge pull request #80 from darkrho/encode-uri-params

encode URI params.
Merge pull request #141 from mtougeron/issue-40

Allow you to change the redis db name in the config. Fixes Issue #40
Add example apiConfigDir to config.json.sample
Tidy up config.json.sample whitespace
Tidy up app.js
Tidy up docs.js and livedocs.js
Merge pull request #137 from rowanhill/configurable-api-config-dir

Allow API definition dir to be configured in config.json
Merge pull request #142 from rowanhill/config-json-tidy

Tidy up config.json.sample whitespace
Merge pull request #143 from rowanhill/app-js-tidy-up

Tidy up app.js