From 402ab057340a29db7a521ff239c5e21ac0c12be8 Mon Sep 17 00:00:00 2001 From: Alistair Jones Date: Sat, 22 Feb 2014 22:48:06 +0000 Subject: [PATCH] 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 --- lib/http-proxy/common.js | 3 ++- test/lib-http-proxy-common-test.js | 33 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index 679812a..66e80f9 100644 --- a/lib/http-proxy/common.js +++ b/lib/http-proxy/common.js @@ -34,7 +34,8 @@ common.setupOutgoing = function(outgoing, options, req, forward) { outgoing.port = options[forward || 'target'].port || (isSSL.test(options[forward || 'target'].protocol) ? 443 : 80); - ['host', 'hostname', 'socketPath'].forEach( + ['host', 'hostname', 'socketPath', 'pfx', 'key', + 'passphrase', 'cert', 'ca', 'ciphers', 'secureProtocol'].forEach( function(e) { outgoing[e] = options[forward || 'target'][e]; } ); diff --git a/test/lib-http-proxy-common-test.js b/test/lib-http-proxy-common-test.js index 559c02e..5cf36c2 100644 --- a/test/lib-http-proxy-common-test.js +++ b/test/lib-http-proxy-common-test.js @@ -250,6 +250,7 @@ describe('lib/http-proxy/common.js', function () { expect(outgoing.headers.host).to.eql('mycouch.com:6984'); }); + 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 () { var outgoing = {}; common.setupOutgoing(outgoing, { @@ -264,6 +265,38 @@ describe('lib/http-proxy/common.js', function () { }) }); + it('should pass through https client parameters', function () { + var outgoing = {}; + common.setupOutgoing(outgoing, + { + agent : '?', + target: { + host : 'how', + hostname : 'are', + socketPath: 'you', + protocol: 'https:', + pfx: 'my-pfx', + key: 'my-key', + passphrase: 'my-passphrase', + cert: 'my-cert', + ca: 'my-ca', + ciphers: 'my-ciphers', + secureProtocol: 'my-secure-protocol' + } + }, + { + method : 'i', + url : 'am' + }); + + expect(outgoing.pfx).eql('my-pfx'); + expect(outgoing.key).eql('my-key'); + expect(outgoing.passphrase).eql('my-passphrase'); + expect(outgoing.cert).eql('my-cert'); + expect(outgoing.ca).eql('my-ca'); + expect(outgoing.ciphers).eql('my-ciphers'); + expect(outgoing.secureProtocol).eql('my-secure-protocol'); + }); }); describe('#setupSocket', function () {