Skip to content

Commit 402ab05

Browse files
apcjjcrugzz
authored andcommitted
Pass HTTPS client parameters.
For more detailed control over HTTPS client behaviour, pass through the parameters listed here: http://nodejs.org/api/https.html#https_https_request_options_callback The `rejectUnauthorized` parameter is omitted, because it overlaps with the existing `secure` parameter: https://github.com/nodejitsu/node-http-proxy/blob/master/README.md#using-https Conflicts: test/lib-http-proxy-common-test.js
1 parent f0db5b3 commit 402ab05

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lib/http-proxy/common.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
3434
outgoing.port = options[forward || 'target'].port ||
3535
(isSSL.test(options[forward || 'target'].protocol) ? 443 : 80);
3636

37-
['host', 'hostname', 'socketPath'].forEach(
37+
['host', 'hostname', 'socketPath', 'pfx', 'key',
38+
'passphrase', 'cert', 'ca', 'ciphers', 'secureProtocol'].forEach(
3839
function(e) { outgoing[e] = options[forward || 'target'][e]; }
3940
);
4041

test/lib-http-proxy-common-test.js

+33
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ describe('lib/http-proxy/common.js', function () {
250250

251251
expect(outgoing.headers.host).to.eql('mycouch.com:6984');
252252
});
253+
253254
it('should correctly set the port to the host when it is a non-standard port when setting host and port manually (which ignores port)', function () {
254255
var outgoing = {};
255256
common.setupOutgoing(outgoing, {
@@ -264,6 +265,38 @@ describe('lib/http-proxy/common.js', function () {
264265
})
265266
});
266267

268+
it('should pass through https client parameters', function () {
269+
var outgoing = {};
270+
common.setupOutgoing(outgoing,
271+
{
272+
agent : '?',
273+
target: {
274+
host : 'how',
275+
hostname : 'are',
276+
socketPath: 'you',
277+
protocol: 'https:',
278+
pfx: 'my-pfx',
279+
key: 'my-key',
280+
passphrase: 'my-passphrase',
281+
cert: 'my-cert',
282+
ca: 'my-ca',
283+
ciphers: 'my-ciphers',
284+
secureProtocol: 'my-secure-protocol'
285+
}
286+
},
287+
{
288+
method : 'i',
289+
url : 'am'
290+
});
291+
292+
expect(outgoing.pfx).eql('my-pfx');
293+
expect(outgoing.key).eql('my-key');
294+
expect(outgoing.passphrase).eql('my-passphrase');
295+
expect(outgoing.cert).eql('my-cert');
296+
expect(outgoing.ca).eql('my-ca');
297+
expect(outgoing.ciphers).eql('my-ciphers');
298+
expect(outgoing.secureProtocol).eql('my-secure-protocol');
299+
});
267300
});
268301

269302
describe('#setupSocket', function () {

0 commit comments

Comments
 (0)