Skip to content
Open
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@ ES|Spain|webservices.amazon.es
UK|United Kingdom|webservices.amazon.co.uk
US|United States|webservices.amazon.com

## Proxy

To allow node-apac through proxy, set the proxy configuration

```javascript
var opHelper = new OperationHelper({
awsId: '[YOUR AWS ID HERE]',
awsSecret: '[YOUR AWS SECRET HERE]',
assocId: '[YOUR ASSOCIATE TAG HERE]',
proxyHostname: '[YOUR PROXY HOSTNAME HERE]',
proxyPort: '[YOUR PROXY PORT HERE]', # default 8080
proxyUsername: '[YOUR PROXY USERNAME HERE]'
proxyPassword: '[YOUR PROXY PASSWORD HERE]'
});
```

## Contributing

Feel free to submit a pull request. If you'd like, you may discuss the change with me first by submitting an issue.
Expand Down
19 changes: 19 additions & 0 deletions lib/operation-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class OperationHelper {
this.baseUri = params.baseUri || OperationHelper.defaultBaseUri
this.xml2jsOptions = Object.assign({}, defaultXml2JsOptions, params.xml2jsOptions)
this.throttler = new Throttler(params.maxRequestsPerSecond)
this.proxyUsername = params.proxyUsername
this.proxyPassword = params.proxyPassword
this.proxyHostname = params.proxyHostname
this.proxyPort = params.proxyPort || 8080

// set version
if (typeof(params.version) === 'string') OperationHelper.version = params.version
Expand Down Expand Up @@ -91,6 +95,21 @@ class OperationHelper {
path: uri,
method: 'GET'
}
if (this.proxyHostname) {
options = {
hostname: this.proxyHostname,
port: this.proxyPort,
path: 'http://' + host + uri,
method: 'GET',
headers: {
Host: host
}
}
if (this.proxyUsername) {
var auth = 'Basic ' + new Buffer(this.proxyUsername + ':' + this.proxyPassword).toString('base64')
options.headers["Proxy-Authorization"] = auth
}
}

if (scheme) options['scheme'] = scheme;

Expand Down