Skip to content

Commit 12cda56

Browse files
committed
ENH: updated agent options in common.setupOutgoing
1 parent f566a42 commit 12cda56

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

lib/caronte.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ proxy.createProxyServer = function createProxyServer(options) {
2828
" { ",
2929
" target : <url string to be parsed with the url module> ",
3030
" forward: <url string to be parsed with the url module> ",
31-
" agent : <object to be passed to http(s).request(...)> ",
31+
" agent : <object to be passed to http(s).request> ",
3232
" ssl : <object to be passed to https.createServer()> ",
3333
" ws : <true/false, if you want to proxy websockets> ",
3434
" xfwd : <true/false, adds x-forward headers> ",
35-
" maxSock: <maximum number of sockets> ",
36-
" agent : <http agent for pooled connections> ",
3735
" } ",
3836
" ",
3937
"NOTE: `options.ws` and `options.ssl` are optional. ",

lib/caronte/common.js

+5-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
var common = exports
2-
, http = require('http')
3-
, https = require('https')
4-
, extend = require('util')._extend
5-
;
1+
var common = exports,
2+
extend = require('util')._extend;
63

74
/**
85
* Copies the right headers from `options` and `req` to
@@ -28,7 +25,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
2825
outgoing.port = options[forward || 'target'].port ||
2926
(~['https:', 'wss:'].indexOf(options[forward || 'target'].protocol) ? 443 : 80);
3027

31-
['host', 'hostname', 'socketPath', 'agent'].forEach(
28+
['host', 'hostname', 'socketPath'].forEach(
3229
function(e) { outgoing[e] = options[forward || 'target'][e]; }
3330
);
3431

@@ -39,16 +36,8 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
3936
if (options.headers){
4037
extend(outgoing.headers, options.headers);
4138
}
42-
43-
if (options.agent){
44-
outgoing.agent = options.agent;
45-
}
46-
47-
if (!outgoing.agent){
48-
var Agent = (~['https:', 'wss:'].indexOf(options[forward || 'target'].protocol) ? https.Agent : http.Agent);
49-
outgoing.agent = new Agent(options.maxSock || 100);
50-
}
51-
39+
40+
outgoing.agent = options.agent || false;
5241
outgoing.path = req.url;
5342

5443
return outgoing;

0 commit comments

Comments
 (0)