From 91715971600bee32e90cec4002fa6404e68d6e38 Mon Sep 17 00:00:00 2001 From: Mark Church Date: Wed, 9 Dec 2015 11:45:33 -0500 Subject: [PATCH] Add support for using an HTTP proxy --- lib/client.js | 6 +++++- package.json | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/client.js b/lib/client.js index ea2b3ed..16996c5 100644 --- a/lib/client.js +++ b/lib/client.js @@ -23,7 +23,8 @@ var Emitter = require('events').EventEmitter , once = require('once') , xml2js = require('xml2js') , StreamCounter = require('stream-counter') - , qs = require('querystring'); + , qs = require('querystring') + , HttpsProxyAgent = require('https-proxy-agent') // The max for multi-object delete, bucket listings, etc. var BUCKET_OPS_MAX = 1000; @@ -284,6 +285,9 @@ Client.prototype.request = function(method, filename, headers){ options.method = method; options.path = pathPrefix + fixedFilename; options.headers = headers; + if(process.env.https_proxy) { + options.agent = new HttpsProxyAgent(process.env.https_proxy); + } var req = (this.secure ? https : http).request(options); req.url = this.url(filename); debug('%s %s', method, req.url); diff --git a/package.json b/package.json index b847c53..16a599a 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,12 @@ }, "bugs": "https://github.com/LearnBoost/knox/issues", "dependencies": { - "mime": "*", - "xml2js": "^0.4.4", "debug": "^1.0.2", + "https-proxy-agent": "^1.0.0", + "mime": "*", + "once": "^1.3.0", "stream-counter": "^1.0.0", - "once": "^1.3.0" + "xml2js": "^0.4.4" }, "devDependencies": { "mocha": "*"