Skip to content

Commit

Permalink
Pass HTTPS client parameters.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
apcj authored and jcrugzz committed Dec 17, 2014
1 parent f0db5b3 commit 402ab05
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/http-proxy/common.js
Expand Up @@ -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]; }
);

Expand Down
33 changes: 33 additions & 0 deletions test/lib-http-proxy-common-test.js
Expand Up @@ -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, {
Expand All @@ -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 () {
Expand Down

0 comments on commit 402ab05

Please sign in to comment.